Loading images in recyclerview with picasso from api

倾然丶 夕夏残阳落幕 提交于 2019-12-01 13:39:21

问题


Add image in RecyclerView from api using picasso


回答1:


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.




回答2:


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'



回答3:


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.




回答4:


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




回答5:


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);


来源:https://stackoverflow.com/questions/41156698/loading-images-in-recyclerview-with-picasso-from-api

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!