I am displaying almost 4,000 images in a loop with image name.
Here is the code which i am using to get my images from drawable folder
for(int i=0; i<count(images_array); i++) {
mDrawableName = images_array(i);
int resID = res.getIdentifier(mDrawableName, "drawable", activity.getPackageName());
Drawable drawable = res.getDrawable(resID);
image.setImageDrawable(drawable);
}
the issues are:
- When the image name is not found in resource folder my app throws me an exception and crashes.
- Is there any better way to load 4000 images from drawable in listview? Is there any way i can check if image is not in drawable then show placeholder image ?