微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

android – 如何将位图加载到Picasso的图像视图中

是的,我正在使用毕加索加载位图.原因是我在我的适配器的一部分中解码URI,并在其他位置加载位图,我读取了 here

You should always call Picasso,even if your URL is null. This way it kNows that the image view was recycled.

所以我试过这个….

Bitmap bitMap;

...

Picasso.with(getContext())
    .load(bitMap)
    .into(imageView);

但是我收到了这个错误

cannot resolve method ‘load(android.graphics.Bitmap)’

解决方法

您不能将Bitmap用于毕加索的加载方法.您只能使用uri,file,url path和int资源id.

如果您从url下载图像,则可以像下面的代码一样:

String url = "your_url";
Picasso.with(context).load(url)
    .placeholder(R.drawable.any_drawable)
    .error(R.drawable.anydrawable).into(your_imageView);

对于其他资源相同,只有load方法参数会根据您使用的资源而改变.

原文地址:https://www.jb51.cc/android/312035.html

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐