If I get the image name as a variable like following:
var imageName = SERVICE.getImg();
Then, how can I get the resource with R.drawa
You need reflection.
Suppose you have R.drawable.image1, if you wanna access it via the String name "image1", following should work:
String Name = "image1";
int id = R.drawable.class.getField(Name).getInt(null);
But notice it only get the Id of the image, you still need the inflater to get the actual drawable from it.