Using setImageDrawable dynamically to set image in an ImageView

Try this,

int id = getResources().getIdentifier("yourpackagename:drawable/" + StringGenerated, null, null);

This will return the id of the drawable you want to access…
then you can set the image in the imageview by doing the following

imageview.setImageResource(id);

Leave a Comment