0

我下载了 Picasso 图像缓存库并尝试让示例代码工作。我从现有代码设置了一个 Android 项目,包括 picasso-2.2.0.jar 和 android-support-v4.jar

但是,当我尝试编译和运行它时,它说 PicassoSampleAdapter 和 SampleWidgetProvider 文件中有错误。

这是有问题的行:

picasso.load(Data.URLS[new Random().nextInt(Data.URLS.length)]) //
    .placeholder(R.drawable.placeholder) //
    .error(R.drawable.error) //
    .transform(new GrayscaleTransformation(picasso)) //
    .into(updateViews, R.id.image, appWidgetIds);

这是错误:

The method into(ImageView, Callback) in the type RequestCreator is not applicable for the arguments (RemoteViews, int, int[])

我检查了 picasso 网站上的文档,实际上, into 采用了这两个参数。对我来说,在这样一个很棒的图书馆上会出现这样的错误似乎是不可思议的,所以我认为这一定是我在设置时做得不对?其他文件没有错误,所以我相信我已经正确设置了。

任何人都可以帮忙吗?当您尝试设置示例项目并运行它时,您是否遇到相同的错误?

4

3 回答 3

3

上的示例适用于 上master的代码master。也就是说,它仅适用于master(2.3.0-SNAPSHOT) 上也存在的 Picasso 库。API的RemoteView变体into()尚未发布。

如果您使用的是 2.2.0 版,则需要使用 2.2.0 版中的示例,可以在此处找到:https ://github.com/square/picasso/tree/picasso-parent-2.2.0/picasso-示例(注意 URL 中的匹配标记)。

于 2014-03-18T22:35:14.057 回答
0

错误出现在您调用的行.into(updateViews, R.id.image, appWidgetIds);它具有此处提到的三个变体http://square.github.io/picasso/javadoc/index.html。您可以将其更改为.into(updateViews),它应该可以工作。假设您想要将最终图像加载到其中updateViewsImageView

于 2014-03-18T20:09:34.580 回答
0

https://github.com/square/picasso/blob/master/picasso/src/main/java/com/squareup/picasso/RequestCreator.java

into 方法接受一个或两个参数。在那里传递你的 imageView 实例。

于 2014-03-18T20:06:53.267 回答