Questions tagged [android-binding-adapter]
101 questions
26
votes
1 answer
Android data binding ObservableList behaviour issue
I find it hard to spot the real raison d'etre of the android.databinding.ObservableList as a data binding feature.
At first it looked like a cool tool to display lists, through data binding, adding them via xml to a RecyclerView.
To do so, I made a…

Carlo Moretti
- 2,213
- 2
- 27
- 41
18
votes
1 answer
Android Data Binding: Missing return statement in generated code when calling custom binding adapter more than once
I am using the android data binding library and MVVM architecture. In the xml layout I define a variable named viewModel of type myViewModel. The layout has several TextInputEditText for which I used the following custom binding adapter:
//makes the…

AaronJ
- 706
- 7
- 17
18
votes
1 answer
Android BindingAdapter order of execution?
I need to understand how the Data Binding Library determine the order of execution for its BindingAdapters. If I have two BindingAdapters for a View and if the View has both the attributes corresponding to those BindingAdapters, how will it…

chaser
- 3,107
- 4
- 29
- 34
16
votes
7 answers
Binding Adapter not working properly
I have a hard time making @BindingAdapter to work in my project.
@BindingAdapter("imageUrl")
public static void setImageUrl(ImageView imageView, String url) {
Log.d("TEST","URL: " + url);
}
Above code shows how it is implemented in my…

Jemil Riahi
- 1,360
- 5
- 18
- 38
12
votes
1 answer
How provide default value in BindingAdapter method in DataBinding Android
I'm working on a binding adapter method to set color span in TextView.
@BindingAdapter("foregroundColorSpan", "start", "end", requireAll = false)
fun TextView.setForegroundColorSpan(color: Int, start: Int = 0, end: Int = text.length - 1) {
val…

Samuel Robert
- 10,106
- 7
- 39
- 60
11
votes
2 answers
How to create Binding Adapter for material.Slider view?
My goal is to 2-way databind material.Slider view to MutableLiveData from my viewmodel:
Of course, it's not working because there…

StayCool
- 421
- 1
- 9
- 23
9
votes
1 answer
Databinding bindingadapter with multiple parameters not working
I´m trying to use databinding for loading an image with Glide, Imageview and Bindingadapter with multiple parameters:
@BindingAdapter(value = ["url", "defaultImage", "placeholder", "circleCrop"], requireAll = false)
fun ImageView.setImageUrl(url:…

Lemao1981
- 2,225
- 5
- 18
- 30
9
votes
3 answers
Two way binding on custom view
I have a componed view in android contains several textViews and one EditText. I defined an attribute for my custom view called text and getText, setText methods. Now I want to add a 2-way data binding for my custom view in a way its bind to inner…

Alireza Ahmadi
- 5,122
- 7
- 40
- 67
8
votes
4 answers
Android - Binding adapter not working
I have create a binding adapter to display picture with picasso, but it doesn't work. I have the following error :
Found data binding errors.
****/ data binding error ****msg:Cannot find the setter for attribute 'app:loadPicture' with parameter…

MLabar
- 523
- 5
- 13
6
votes
1 answer
How to use Inverse Binding Adapter in Kotlin for converting Lowercase text to Uppercase?
I am creating an android application where I want to use a feature in which a text that we have entered into an editText field can be converted into uppercase at runtime in that particular editText field only.
I have tried with this…

JayShah
- 63
- 5
6
votes
3 answers
BindingAdapter LiveData first value always null
I'm trying to handle a LiveData value (profilePicture: Bitmap) within a BindingAdapter function but the first value is always null. The binding adapter is a ViewSwitcher with ProgressBar and ImageView.
Getting profile picture from firebase like…

Erkan
- 140
- 2
- 11
6
votes
3 answers
Data binding adapter. How to get view by id reference?
I want to specify view reference as atribute to ImageView
@BindingAdapter(value = {"imageUrl", "progressView"}, requireAll = false)
public static void setImageUrl(ImageView imageView, String url, @IdRes int progressBar) {
Context context =…

Chickin Nick
- 517
- 1
- 6
- 21
5
votes
3 answers
If a binding adapter provides the getter, check that the adapter is annotated correctly and that the parameter type matches
I have a little problem with databindig in Android.
I want to set an ImageView's visibility through databindig, and I think I have done everything that can be found on Android blogs in connection with databinding, though I get that build error…

pedro
- 83
- 1
- 2
- 9
5
votes
3 answers
Why is this BindingAdapter not working in Kotlin?
I have a ViewModel with:
val imageUrl = ObservableField()
My layout XML has:
I have a BindingAdapters file with a top level function:
@BindingAdapter("url")
fun…

SilentByte
- 1,098
- 1
- 10
- 21
5
votes
1 answer
Set via Data-Binding API a well known attribute value
I have an custom attribute from a custom view defined line this: