How to replace R.drawable.“someString”

后端 未结 6 984
长发绾君心
长发绾君心 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:27

    public int getIdentifier(String name, String defType, String defPackage);

    name - name of the image
    defType - it will be drawable for your case
    defPackage - default package of your app (I think you can use getPackage() on the activity for this)

提交回复
热议问题