How to access resource with dynamic name in my case?

前端 未结 5 1998
生来不讨喜
生来不讨喜 2020-12-01 04:02

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

5条回答
  •  再見小時候
    2020-12-01 04:48

    You can use getIdentifier method which will give you the resource id by it's name. Check this thread for more details.

提交回复
热议问题