我有这样的代码:
String s = "replace__menu__" + data.imageid + ".png";
int RID = this.getApplicationContext().getResources().getIdentifier(s, "drawable-hdpi", getPackageName());
String s =指令设置的值与我的res/draw_hdpi文件夹中的名称相同。但是,返回值将RID设置为值0
知道为什么我的代码不工作吗?我做错了什么吗?
试试这个
String s = "replace__menu__" + data.imageid; // image name is needed without extention
int RID = this.getApplicationContext().getResources().getIdentifier(s, "drawable", getPackageName());
".png" is not part of a ressource name
"drawable-hdpi" I would try just 'drawable' instead