I have 700 images in Drawable and i have a list of image name and i need to load it into imageview programily
Image is in webp formate and less than 100kb
images in recycler view
where is wrong
Java Code
Drawable drawable = mContext.getResources().getDrawable(mContext.getResources().getIdentifier(mData.get(position).getImage(), "drawable", mContext.getPackageName()));
holder.image.setImageDrawable(drawable);
Layout
<ImageView
android:id="@+id/fish_image"
android:layout_width="match_parent"
android:scaleType="fitXY"
android:minWidth="100dp"
android:minHeight="100dp"
android:background="#ffffff"
android:layout_height="wrap_content"
/>
I have 700 images in Drawable and I have a list of image name and I need to load it into image view programmatically is there any other solution
Update it worked
i moved image to Assets folder and load it from there
try {
// get input stream
InputStream ims = mContext.getAssets().open(mData.get(position).getImagename()+".webp");
// load image as Drawable
Drawable d = Drawable.createFromStream(ims, null);
// set image to ImageView
holder.image.setImageDrawable(d);
ims .close();
}
catch(IOException ex)
{
Log.e("image_io",ex.getMessage()+"");
// return;
}