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
R.drawa
You can use getIdentifier method which will give you the resource id by it's name. Check this thread for more details.