change integer image resource to drawable api 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));