Android getResourcesgetIdentifier没有返回ID

Android getResourcesgetIdentifier没有返回ID,第1张

概述我有像这样的代码:Strings="replace__menu__"+data.imageid+".png";intRID=this.getApplicationContext().getResources().getIdentifier(s,"drawable-hdpi",getPackageName());Strings=指令设置的值与res/drawable-hdpi文件夹中的名称之一相同.但是,返

我有像这样的代码:

String s = "replace__menu__" + data.imageID + ".png";int RID = this.getApplicationContext().getResources().getIDentifIEr(s, "drawable-hdpi", getPackagename());

String s =指令设置的值与res / drawable-hdpi文件夹中的名称之一相同.但是,返回值将RID设置为值0

知道为什么我的代码无效吗?难道我做错了什么?

解决方法:

试试这个

String s = "replace__menu__" + data.imageID;  // image name is needed without extentionint RID = this.getApplicationContext().getResources().getIDentifIEr(s, "drawable", getPackagename());
总结

以上是内存溢出为你收集整理的Android getResources / getIdentifier没有返回ID全部内容,希望文章能够帮你解决Android getResources / getIdentifier没有返回ID所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1114595.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-29
下一篇 2022-05-29

发表评论

登录后才能评论

评论列表(0条)

保存