嗨,我尝试用数据绑定更新imageview,但我想知道如何正确地做到这一点.
我的变种
@BindingAdapter({"bind:someImage"})
public void loadIt(ImageView view, String imageUrl) {
Picasso.with(view.getContext())
.load(getSomeImage())
.placeholder(android.R.drawable.alert_dark_frame)
.into(view);
}
public void setSomeImage(){
notifyPropertyChanged(BR.someImage);
}
Run Code Online (Sandbox Code Playgroud)
我的布局
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imagePath"
app:imageUrl="@{var.someImage}"/>
Run Code Online (Sandbox Code Playgroud)