Questions tagged [android-databinding]

Data Binding Library to write declarative layouts and minimize the glue code necessary to bind your application logic and layouts. The Data Binding Library offers both flexibility and broad compatibility — it's a support library, so you can use it with all Android platform versions back to Android 2.1 (API level 7+).

The Data Binding Library offers both flexibility and broad compatibility — it's a support library, so you can use it with all Android platform versions back to Android 2.1 (API level 7+).

To use data binding, Android Plugin for Gradle 1.5.0-alpha1 or higher is required.

Official API Documentation

Data Binding Guide

2508 questions
89
votes
32 answers

android: data binding error: cannot find symbol class

I am getting started for using DataBinding feature. I am facing problem with it. Error:(21, 9) error: cannot find symbol class ContactListActivityBinding build.gradle(Module: app) apply plugin: 'com.android.application' android { …
Chintan Soni
  • 24,761
  • 25
  • 106
  • 174
87
votes
4 answers

What are the pros and cons of android data-binding?

Both of my colleague and I have experience in MVVM of Web App, while we are new to native android development. Now we have contrary opinions about android data-binding -- I'm a fan of it while he is not. My Arguments: Reduces boilerplate code which…
lzl124631x
  • 4,485
  • 2
  • 30
  • 49
86
votes
9 answers

How to use data-binding in Dialog?

I am having trouble in implementing databinding in a Dialog. Is it possible? Below is my xml.
Nidhin Rejoice
  • 1,367
  • 1
  • 16
  • 26
80
votes
6 answers

Android Data Binding @BindingConversion failure for int to string

Ran into a mysterious problem when trying to make a @BindingConversion for int to string. The following code works for floats to strings: xml: ... ...
Dave
  • 1,896
  • 2
  • 14
  • 15
77
votes
3 answers

Android DataBinding Custom Binding Adapter Warning

I followed the data binding documentation for Custom Binding Adapter for image loading from official Android Developers site: http://developer.android.com/tools/data-binding/guide.html After successfully compiling the code I get a warning which…
asad.qazi
  • 2,449
  • 3
  • 23
  • 35
76
votes
7 answers

Kotlin custom attribute databinding

I am trying to set custom attribute using the Android DataBinding Library in my Kotlin project like this: Layout
Akshata
  • 1,005
  • 2
  • 12
  • 22
68
votes
13 answers

Android Data Binding: visibility on include tag

As per http://developer.android.com/tools/data-binding/guide.html#imports, we can have such simple expressions in visibility: But when I try to do the same in an include…
Ishaan Garg
  • 3,014
  • 3
  • 25
  • 28
66
votes
4 answers

Data Binding with srcCompat

I'm using the new vector drawable support in Support Lib v23.2 with app:srcCompat & trying to set its drawable via data binding.
Ishaan Garg
  • 3,014
  • 3
  • 25
  • 28
64
votes
7 answers

Use DataBinding library to set background color resource or null

I would like to set background color or null on my view using DataBinding library but I get an exception trying to run it. java.lang.NullPointerException: Attempt to invoke virtual method 'int java.lang.Integer.intValue()' on a null object…
Damian Petla
  • 8,963
  • 5
  • 44
  • 47
63
votes
29 answers

Can't resolve Android databinding class

While using data binding , I am not able to get class MainActivityBinding as per Data Binding Guide My layout name is activity_main.xml. I am also see Android - DataBinding - How and when the Binding classes will be generated? but it can't help me.
pRaNaY
  • 24,642
  • 24
  • 96
  • 146
61
votes
3 answers

Data binding: set property if it isn't null

Cannot understand... How to set some property of view only if variable field isn't null? For example
Denis Sologub
  • 7,277
  • 11
  • 56
  • 123
61
votes
10 answers

How to databind to onTextChanged for an EditText on Android?

In Yigit Boyar and George Mount's talk on Android Databinding they illustrate how easy it is to bind to TextWatcher's onTextChanged (at 13:41). On a Button. Are their slides wrong? First of all the Button View doesn't have an onTextChanged property.…
Nilzor
  • 18,082
  • 22
  • 100
  • 167
61
votes
8 answers

DataBinding: How to get resource by dynamic id?

I know that it is possible to reference resources in layout by their resource id: android:text="@{@string/resourceName}" However, I would like to reference resource by id which is known only at runtime. As a simple example, imagine we have such…
Dmitry Zaytsev
  • 23,650
  • 14
  • 92
  • 146
56
votes
17 answers

Data Binding Android - Type parameter T has incompatible upper bounds : ViewDataBinding and MainActivity

I am using Android Studio 2.0 Preview 4. I'm using Android SDK tools 25 rc1. This error persists no matter how many times I clean / rebuild project. File->Invalidate Caches and restart also doesn't work. I'm not able to run the most basic example of…
Chirag Shenoy
  • 613
  • 1
  • 5
  • 10
55
votes
9 answers

Using DataBinding library for binding events

I'm trying to bind events with views in xml using DataBinding Library shipped with Android M. I'm following examples from Android Developers and implementing step-by-step. for the view's attributes like visibility,text its working fine but if I try…