How to set an imageView’s image from a string?

if you have the image in the drawable folder you are going about this the wrong way.

try something like this

Resources res = getResources();
String mDrawableName = "logo_default";
int resID = res.getIdentifier(mDrawableName , "drawable", getPackageName());
Drawable drawable = res.getDrawable(resID );
icon.setImageDrawable(drawable );

Leave a Comment