【问题标题】:How to load a bitmap into an image-view with Picasso如何使用毕加索将位图加载到图像视图中
【发布时间】:2016-03-07 18:49:29
【问题描述】:

是的,我正在使用 Picasso 加载位图。原因是我在适配器的一部分中解码 URI,并在另一部分中加载位图,我读到 here p>

即使您的 URL 为空,您也应该始终调用 Picasso。这样它就知道图像视图被回收了。

所以我尝试了这个....

Bitmap bitMap;

...

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

但我收到了这个错误

无法解析方法'load(android.graphics.Bitmap)'

【问题讨论】:

  • 为什么你需要Picasso你已经有了位图?
  • @Blackbelt 你说得对。
  • 您不能将Bitmap 用于load 方法,您可以使用uri、file、url path 和int resource id
  • 你是如何创建bitmap的???如果您通过uri 或url 或file 创建bitmap,则将该资源作为参数放入您的load 方法中
  • @the_prole 加载位图是不可能的。毕加索它只包含字符串 path , uri , file 。

标签: android picasso android-bitmap


【解决方案1】:

您不能将位图用于Picasso 的加载方法。您只能使用uri , file , url path and int resource id。

如果你是从 url 下载图片,那么你可以像下面的代码一样:

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

对于其他资源相同,只有 load 方法 parameter 会根据您使用的 resource 进行更改。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-09-06
    • 1970-01-01
    相关资源
    最近更新 更多