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方法参数会根据您使用的资源而改变.

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...