set string image in image resource code example
Example 1: how to set drawable name to imageview programmatically
String uri = "@drawable/myresource";
int imageResource = getResources().getIdentifier(uri, null, getPackageName());
imageview= (ImageView)findViewById(R.id.imageView);
Drawable res = getResources().getDrawable(imageResource);
imageView.setImageDrawable(res);
Example 2: how to set image dynamically in android
String fnm = "cat";
String PACKAGE_NAME = getApplicationContext().getPackageName();
int imgId = getResources().getIdentifier(PACKAGE_NAME+":drawable/"+fnm , null, null);
System.out.println("IMG ID :: "+imgId);
System.out.println("PACKAGE_NAME :: "+PACKAGE_NAME);
your_image_view.setImageBitmap(BitmapFactory.decodeResource(getResources(),imgId));