How to load a bitmap into an image-view with Picasso

the_prole picture the_prole · Dec 3, 2015 · Viewed 15.6k times · Source

Yes, I am using Picasso to load a bitmap. The reason is I am decoding URIs in one part of my adapter, and loading bitmaps in another, and I read here that

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

So I tried this....

Bitmap bitMap;

...

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

But I got this error

cannot resolve method 'load(android.graphics.Bitmap)'

Answer

Pankaj picture Pankaj · Dec 3, 2015

You cant put Bitmap for load method of Picasso. You can use only uri , file , url path and int resource id.

If You are downloading image from url then you can do like as below code:

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

For other resource its same, only load method parameter would gets changed depending on the resource you are using.