Answer the question
In order to leave comments, you need to log in
How to get image resource ID by name?
Hello everyone, the task is this: to replace the picture in the Activity, having only the file name from the database.
I can't figure out how to get the resource id from the file name. I found a lot of options, but they don’t work, or I’m doing something wrong.
There was such an option
int imgRes = R.drawable.class.getField(itemImage).getInt(getResources());
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question