我有这样的代码:
String s = "replace__menu__" + data.imageid + ".png";
int RID = this.getApplicationContext().getResources().getIdentifier(s, "drawable-hdpi", getPackageName());
The 字符串 s =指令设置的值与我的 res/drawable-hdpi 文件夹中的名称之一相同。然而,返回值设置RID到值0
知道为什么我的代码不起作用吗?难道我做错了什么?
Try this
String s = "replace__menu__" + data.imageid; // image name is needed without extention
int RID = this.getApplicationContext().getResources().getIdentifier(s, "drawable", getPackageName());
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)