-4

Add image in RecyclerView from api using picasso

Deepak
  • 187
  • 1
  • 1
  • 10

6 Answers6

22

Image loading using Picasso is very easy, you can do it like this way Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView); and in their website you can get every details. In your case you can parse every image URL and use RecyclerView to show them along with Picasso.

Sierisimo
  • 639
  • 8
  • 21
androidcodehunter
  • 21,567
  • 19
  • 47
  • 70
12
Picasso.get().load("http://i.imgur.com/DvpvklR.png").into(imageView)

In the new versions of Picasso you don't need the context anymore. I'm using:

implementation 'com.squareup.picasso:picasso:2.71828'
Daniel Bastidas
  • 1,795
  • 1
  • 9
  • 15
7

In the new versions of Picasso used get() Picasso latest version Picasso library: 2.71828

Picasso
.get()
.load("You Img Path Place Here")
.resize(width, height)
.noFade()
.into("Path set ImageView");

Used latest picasso version

 implementation 'com.squareup.picasso:picasso:2.71828'
Abhinav Suman
  • 940
  • 1
  • 9
  • 29
Shahzad Ishaq
  • 91
  • 1
  • 4
6

Try this

String img_url = "YOUR IMAGE URL";
    if (!img_url.equalsIgnoreCase(""))
        Picasso.with(context).load(img_url).placeholder(R.drawable.user_image)// Place holder image from drawable folder
       .error(R.drawable.user_image).resize(110, 110).centerCrop()
       .into("IMAGE VIEW ID WHERE YOU WANT TO SET IMAGE");

Happy coding.

Sanwal Singh
  • 1,765
  • 3
  • 17
  • 35
2

You can load image using picasso like this way

Picasso.with(context).load(android_versions.get(i).getAndroid_image_url()).resize(120, 60).into(viewHolder.img_android);

https://www.learn2crack.com/2016/02/image-loading-recyclerview-picasso.html

Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
0

Here ctx is context, list.getImage_full_path()) is image coming from server, in placeholder a static image is placed if image is not loaded, on error kent is name of image and into(servicecart_image) is placed in XML so image is loaded there

 Picasso.with(ctx).load(list.getImage_full_path()).resize(160, 200).placeholder(R.drawable.kent)
                .error(R.drawable.kent).into(servicecart_image);
S.S. Anne
  • 15,171
  • 8
  • 38
  • 76
Deep Adhia
  • 382
  • 4
  • 11