How to replace R.drawable.“someString”

后端 未结 6 989
长发绾君心
长发绾君心 2021-02-02 10:00

I have some Images in my project. The name of the image is stored in a String and I would like to setImageResource(R.drawable.\".....\"); with the string of the image name but t

6条回答
  •  花落未央
    2021-02-02 10:24

    Use

    getResources().getIdentifier("NAME_OF_IMAGE", "drawable", context.getPackageName())
    

提交回复
热议问题