Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

app:imageUrl="@{imageUrl}能运行起来吗? #3

Open
pengwei1024 opened this issue Jul 10, 2015 · 7 comments
Open

app:imageUrl="@{imageUrl}能运行起来吗? #3

pengwei1024 opened this issue Jul 10, 2015 · 7 comments

Comments

@pengwei1024
Copy link

@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方法报错。

@liangfeidotme
Copy link
Owner

imageUrl 是利用 data binding 适配的属性,编译会出错吗?

@pengwei1024
Copy link
Author

报错如下:annot find the setter for attribute 'imageUrl' on android.widget.ImageView with parameter type java.lang.String.

@liangfeidotme
Copy link
Owner

几个checkpoint

  1. 代码没改过吧?
  2. imageUrl 的 namespace 不是 android
  3. AS 升级到1.3

@pengwei1024
Copy link
Author

环境我都配置好了,就这个东西编译不过。我对这种写法也觉得特别奇怪,app:imageUrl="@{url}"这样写法不是会去找ImageView属性吗?而且就对一个静态方法添加注解,这样是不是太莫名其妙了?楼主你能运行出来并加载图片么?

@liangfeidotme
Copy link
Owner

代码运行没问题,你是跑的我的代码吗

@zhangxiaang
Copy link

to @pengwei1024
可以把你的attribute_setters.xml文件贴出来看看吗?我猜测是否是xml文件有改动?

@ysmintor
Copy link

    @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,我也不知道为什么。

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants