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 ViewModel. Nothing special.
<ImageView
android:id="@+id/image_holder"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scaleType="centerCrop"
android:layout_below="@id/profile_container"
app:imageUrl="@{item.imageUrl}"
tools:src="@drawable/placeholder_image"/>
This does not work. namespace app is unbound. So what am i missing. I tried following https://medium.com/google-developers/android-data-binding-custom-setters-55a25a7aea47#.6ygaiwooh and see how they set bindingAdapter. But there is something i have missed
I suggest to use "bind" namespace for bindable attributes and use same names for adapter parameter and layout attribute.
Adapter:
Layout:
where namespace "app" was replaced to "bind". On your Layout root: