Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass multiple arguments via xml for a custom setter when using Android data binding

Suppose I have a custom setter method where I need two arguments:

@BindingAdapter({"imageUrl", "placeholder"})
public static void loadImage(ImageView imageView, String imageUrl, Drawable drawable) {
     Picasso.with(imageView.getContext()).load(imageUrl).placeholder(drawable).into(imageView);
}

What would the corresponding xml look like?

like image 436
TomTaila Avatar asked Apr 28 '16 17:04

TomTaila


1 Answers

Looks like it can be done like this:

<ImageView app:imageUrl=“@{data.imageUrl}” app:placeholder=“@{@drawable/placeholder}”/>

see http://developer.android.com/intl/es/tools/data-binding/guide.html

like image 63
TomTaila Avatar answered Sep 29 '22 06:09

TomTaila