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

戏子无情 提交于 2021-01-27 02:56:45

问题


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?


回答1:


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



来源:https://stackoverflow.com/questions/36921406/how-can-i-pass-multiple-arguments-via-xml-for-a-custom-setter-when-using-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!