I have to show a drawable
from res
into an ImageView
. In this app, I'm using Picasso for some reasons.
In this case, I need to load the drawable
using its URI and not its id. To do that, here is my code:
uri = Uri.parse(ContentResolver.SCHEME_ANDROID_RESOURCE + "://"+context.getPackageName()+"/drawable/" + drawableName);
where drawableName used here are file names rather than their resource ids.
Then
Picasso.with(context).load(uri).into(imageView);
I know for sure that drawable name is correct, but Picasso seems it does not like this uri.
You should use ContentResolver to open resource URIs: Uri uri = Uri. parse("android. resource://your.package.here/drawable/image_name"); InputStream stream = getContentResolver().
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.
If the images is in your drawable folder then you can just load it.
Picasso.with(context).load(R.drawable.drawableName).into(imageView);
and picasso will load it no need for an Uri.
Found the answer. Unfortunately, Picasso do not allow drawable loading via URI. It is an incoming feature.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With