https://itpcb.com/a/150983

@BindingAdapter(value = {"imageUrl", "placeDrawableId", "errorDrawableId"}, requireAll = true)//requireAll表示所有参数都必须有
public static void setImageUrl(ImageView imageView, String imageUrl, int placeDrawableId, int errorDrawableId) {
    ImageLoadUtils.loadImageUrl(getApplicationContext(), imageUrl, placeDrawableId, errorDrawableId, imageView););
}
<ImageView
        android:id="@+id/iv_image"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:scaleType="centerCrop"
        app:imageUrl="@{item.imageUrl}"
        app:placeDrawableId="@{item.placeDrawableId}"
        app:errorDrawableId="@{item.errorDrawableId}"/>

0 条评论

发表回复

您的电子邮箱地址不会被公开。