android-databinding

How DataBindingComponents works on per-layout basis? [duplicate]

怎甘沉沦 提交于 2019-12-23 03:51:06
问题 This question already has an answer here : How do I access an instance variable inside a BindingAdapter when using Android Data Binding? (1 answer) Closed 2 years ago . Android DataBinding Library is a charming lib for me to learn MVVM. Now there's a problem, how to play an animation before update the text to the UI, on a per-layout basis . (Not a solution for global layouts using BindingAdapter , using a static binding adapter.) From the IO16 video I know perhaps I can use

Databinding and included layouts: Cannot find setter attribute for onClick

孤街浪徒 提交于 2019-12-22 11:34:12
问题 I'm trying to set an OnClickListener for an <include> d layout, but receive a data binding error at compile time stating that data binding "Cannot find the setter for attribute 'android:onClick' with parameter type android.view.View.OnClickListener". Context here is that I'm using data binding to inflate the included layout, so that I can pass values into it from a viewModel that I've bound to the including layout. I've tried various syntax for the data binding expression: @{viewModel:

Pass generic list into <include>

核能气质少年 提交于 2019-12-22 09:40:02
问题 Have two complex layouts and one is included into another. Trying to pass list of some custom objects into included layout, but build fails with following error: Error:Execution failed for task ':core:compileDebugJavaWithJavac'. > java.lang.RuntimeException: Found data binding errors. ****/ data binding error ****msg:cannot find type element for List file:D:\myproject-android\core\src\main\res\layout\view_header.xml loc:101:27 - 101:42 ****\ data binding error **** view_header.xml: <layout

Switch case in Data Binding

心已入冬 提交于 2019-12-22 09:28:02
问题 Is it possible to write switch case with android Data Binding? Suppose i have 3 conditions like value == 1 then print A value == 2 then print B value == 3 then print C Does there any way to do this stuff in xml by using Data Binding? I know we can implement conditional statement like android:visibility="@{age < 13 ? View.GONE : View.VISIBLE}" But here i am searching for switch case statement. 回答1: No, as far as I know it is not possible and also would make the xml files really unreadable. I

Two-way binding cannot resolve a setter for java.lang.String property

余生颓废 提交于 2019-12-22 06:25:45
问题 I am playing with the two-way binding of the data binding API which was introduced in Android Studio 2.1 AFIK. I get this interesting error: Error:Execution failed for task ':app:compileDebugJavaWithJavac'. > java.lang.RuntimeException: Found data binding errors. ****/ data binding error ****msg:The expression address.street cannot cannot be inverted: Two-way binding cannot resolve a setter for java.lang.String property 'street' file:/path/to/layout.xml loc:34:37 - 34:50 ****\ data binding

Using LiveData to set visibility of TextView

久未见 提交于 2019-12-22 04:58:10
问题 I want to toggle the visibility of a TextView using LiveData. There have been a few other posts on setting the visibility with databinding, but these use Observables, whereas I want to leverage the (newer) LiveData. In particular, use a LiveData. Using this documentation, and a few SO posts, I have already learned that you should correctly align your getter of your observable (LiveData) so that the return type matches the type expected by the setter for the View attribute you want to set.

app:visibleGone cannot resolve on android Databinding

杀马特。学长 韩版系。学妹 提交于 2019-12-22 04:01:16
问题 When I build the project. I'm getting error on app:visibleGone I'm also enable true to dataBinding in build.gradle and using android architecture components and mvvm. project targetSdkVersion is 26 and support lib version is 26.0.1 . Below is the error message error: package com.****.****.databinding does not exist error: cannot find symbol class ActivityMainBinding Cannot find the setter for attribute 'app:visibleGone' with parameter type boolean on android.widget.Button. here is my activity

Android Data Binding build error: [data binding plugin]: failed to setup data binding

流过昼夜 提交于 2019-12-22 03:24:10
问题 I'm playing around with the Android Data Binding library from Google, which I had working at one point. Now, it seems that "something" has changed and it is causing a problem for the Data Binding library. I'm stumped by a very generic error that is proving difficult to debug, a [data binding plugin]: failed to setup data binding . AFAIK, this error is thrown when there the Data Binding library has a problem with one of your layout file (say a typo in a binding). The question is, how can one

Android DataBinding: @BindingAdapter in Kotlin does not recognize lambdas

☆樱花仙子☆ 提交于 2019-12-22 03:10:06
问题 This is my BindingAdapter : @BindingAdapter(value = *arrayOf("bind:commentsAdapter", "bind:itemClick", "bind:avatarClick", "bind:scrolledUp"), requireAll = false) fun initWithCommentsAdapter(recyclerView: RecyclerView, commentsAdapter: CommentsAdapter, itemClick: (item: EntityCommentItem) -> Unit, avatarClick: ((item: EntityCommentItem) -> Unit)?, scrolledUp: (() -> Unit)?) { //Some code here } initWithCommentsAdapter is a top level function This is my layout (an essential part): <layout

Android Studio 2.2 preview throwing error while implementing databinding

别说谁变了你拦得住时间么 提交于 2019-12-21 07:37:24
问题 I have updated my android studio to 2.2 preview 1 and applied the specified dependencies for google and firebase as specified but still getting the following error EmptyThrowable: Wrong dependency type: class com.android.tools.idea.databinding.DataBindingUtil$LightBRField dataBinding { enabled true } 回答1: You can update the Google repository in the Android Software Development Kit (SDK). The fastest way to do it to click: Help> Check for updates 回答2: Just use latest Android Studio 3.1.3 or