0

I am completely amateur in programming. I've started to learn it a few days ago. It means,

mImageName.setImageDrawable(getDrawable(R.drawable.X));

where X is a name of drawable file, but for X I have to have:

mQuestionLibrary.getImage(mQuestionNumber);//the name of drawable

How to merge this?

Piotr M.
  • 11
  • 7
  • 1
    Possible duplicate of [Android, getting resource ID from string?](https://stackoverflow.com/questions/4427608/android-getting-resource-id-from-string) – Bö macht Blau Oct 16 '17 at 16:57

1 Answers1

0

OK, I've obtained the solution.

mImageName.setImageResource(getResources().getIdentifier("@drawable/" + this.mQuestionLibrary.getImage(mQuestionNumber), null, getPackageName()));
Piotr M.
  • 11
  • 7