问题:
代码中获取String.xml中的字符串?
解决办法:
1.在activity里:
方法一:this.getString(R.string.resource_name);
方法二:getResources().getString(R.string.resource_name);
2.在其他java文件(必须有Context或aplication)
方法一: context.getString(R.string.resource_name);
方法二: application.getString(R.string.resource_name);
本文介绍在Android开发中如何从String.xml文件中获取字符串资源的方法。包括在Activity和其他Java文件中通过不同方式调用以实现资源读取。
1802

被折叠的 条评论
为什么被折叠?



