android-databinding

Howto androidx-databinding for onClick to static method with parameter

筅森魡賤 提交于 2019-12-11 08:45:24
问题 (Note: this is a follow up question to Is it possible to use androidx-navigation with onClick-databinding without writing boilercode in Fragment? I want to use androidx-databinding to handle onClick calling a static method with parameters Utils.myNavigate(...) via the xml-layout-file My Code below is verifyed by the compile process but is never called when i click on the button. How to fix this? My Layoutfile: <layout ...> <data> <import type="de.k3b.androidx.navigationdemo.R" /> <import type

Is it possible to use androidx-navigation with onClick-databinding without writing boilercode in Fragment?

核能气质少年 提交于 2019-12-11 07:33:25
问题 I want to implement an androidx-navigation by using databinding instead of implementing onClick handler in code I have a List-fragment with a livedata element selectedItemId and want to open a correspondeng detail-fragment when pressing the edit button. Is something similar to this possible <layout> <data> <!-- assuming that com.example.MyGeneratedNavigation was generated from .../res/navigation/my_navigation.xml --> <variable name="myNavigation" type"com.example.MyGeneratedNavigation" />

Cannot set string array for spinner using Android data binding

我与影子孤独终老i 提交于 2019-12-11 06:34:23
问题 I have a spinner now and I want to load the data to the spinner with data binding feature. I tried to find the way to declare the string array in the XML(https://developer.android.com/topic/libraries/data-binding/index.html#expression_language) but no satisfied result is found. <layout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:apps="http://schemas.android.com/apk/res-auto"> <data> <import type="android.util.SparseArray"/> <variable name="statuslist" type="SparseArray

Databinding error - Could not find accessor

送分小仙女□ 提交于 2019-12-11 06:27:18
问题 I googled but still didn't find solution for me. This is my xml: <?xml version="1.0" encoding="utf-8"?> <layout xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools"> <data> <import alias="noteViewModel" type="com.app.screen.createnote.CreateNoteViewModel" /> </data> <LinearLayout android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical">

DataBinding not working in module

删除回忆录丶 提交于 2019-12-11 02:39:16
问题 I'm using data binding within my app. I have an application module and the data binding is working successfully. However, I also have a 'home-module' I'm trying to use the same techniques, but the data binding is erroring in the xml with the following: Error:(63, 34) No resource type specified (at 'onClick' with value '@{viewModel::onButtonClicked}'). I've found this bug report which suggests this was an issue but it's been fixed. I can't see any issues with the code, I think the problem is

Android - Wrong layout direction when switching RTL vs LTR many times

北城余情 提交于 2019-12-11 02:08:34
问题 When I switch my app language between EN and AR (during runtime) the views behave correctly by moving from the LTR to the RTL but when I start stressing the app by switching languages many times the layout direction become missy and I get RTL elements when the app is supposed to show LTR elements. Sometimes the layout direction is not refreshed anymore. As workaround I have to set the layout direction programmatically for those views. binding.spinner.setLayoutDirection(LocaleUtil.isRtl(this)

Generated ViewDataBinding class in Android Studio 3.2.1 has an error when view layout data variable type is contained in a subpackage

◇◆丶佛笑我妖孽 提交于 2019-12-11 00:45:15
问题 I have my viewmodels contained in a "ViewModels" package. When setting one of them as a data variable type in my fragment layout xml file the generated ViewDataBinding class attempts to import the package as if it were a file. For example: import com.xyz.myapp.ViewModels; Rather than: import com.xyz.myapp.ViewModels.*; It then goes on to reference the viewmodel as ViewModels.MyFragmentViewModel causing further errors. I found that a workaround for this is to put all my viewmodel files in my

Android Multi Module Project With TestCoverageEnabled Throws Data Binding Errors

守給你的承諾、 提交于 2019-12-10 20:42:51
问题 I have a multi module project which is structured something like this. Here is the code to play around with this error: https://github.com/ajitsing/MultiModuleAndroid Root |- App Module (Application, Data binding enabled) |- Lib Module (Library, Data binding enabled) Main module depends on the Lib module. Lib module contains all the android tests. When I run the androidTests of just lib module with testCoverageEnabled it throws some weird data binding error. All these error are for custom

Data Binding with Android Studio 3.0 Canary 3

徘徊边缘 提交于 2019-12-10 20:02:12
问题 I am trying to use DataBinding in my existing project. As per the documentation I added below lines in app module's build.gradle and compiled the project. dataBinding { enabled = true } I got the below error: Could not resolve all dependencies for configuration ':app:devDebugCompileClasspath'. Could not find com.android.databinding:baseLibrary:3.0.0-alpha3. Searched in the following locations: file:/C:/Users/incnayak/AppData/Local/Android/sdk/extras/m2repository/com/android/databinding

Cusom event attributes in android bindings app:onMyEvent

余生长醉 提交于 2019-12-10 17:49:41
问题 Is there any way to wire up custom onSomeEventListener to the attribute using binding library? Examples provided for onClick are simple and they all use 'on' prefix and single-method interface listeners, and what about 'add' prefix and more complicated scenarios? Imagine I want to use custom wire up logic on RecyclerView.addOnItemTouchListener, determining the child view was touched from SimpleOnItemTouchListener.onTouchEvent and passing it to my view model, how can I achieve this? I want to