Open pengwei1024 opened 9 years ago
imageUrl
是利用 data binding
适配的属性,编译会出错吗?
报错如下:annot find the setter for attribute 'imageUrl' on android.widget.ImageView with parameter type java.lang.String.
几个checkpoint
环境我都配置好了,就这个东西编译不过。我对这种写法也觉得特别奇怪,app:imageUrl="@{url}"这样写法不是会去找ImageView属性吗?而且就对一个静态方法添加注解,这样是不是太莫名其妙了?楼主你能运行出来并加载图片么?
代码运行没问题,你是跑的我的代码吗
to @pengwei1024 可以把你的attribute_setters.xml文件贴出来看看吗?我猜测是否是xml文件有改动?
@BindingAdapter({"imageUrl", "error"})
public static void loadImage(ImageView view, String url, Drawable error) {
Log.d(App.TAG, "load image");
Picasso.with(view.getContext()).load(url).error(error).into(view);
}
楼主@BindingAdapter({"bind:imageUrl", "bind:error"})
中多了bind,我也不知道为什么。
@BindingAdapter({"bind:imageUrl", "bind:error"}) public static void loadImage(ImageView view, String url, Drawable error) { Picasso.with(view.getContext()).load(url).error(error).into(view); } 我这样写提示TextView没有imageUrl方法报错。