Bindable must be on a member in an Observable class.报错解决
在使用databinding时报错,实体类必须继承BaseObservable,我的实体如下:
public class Food extends BaseObservable {
private String img;
private String description;
private String keywords;
public Food(String img, String description, String keywords) {
this.img = img;
this.description = description;
this.keywords = keywords;
}
@BindingAdapter("bind:img")
public static void getImage(ImageView view, String url){
Picasso.with(view.getContext()).load(url).into(view);
}
@Bindable
public String getImg() {
return img;
}
public void setImg(String img) {
this.img = img;
}
@Bindable
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
@Bindable
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
}