android获取string.xml的值
来源:互联网 发布:遗传算法本质 编辑:程序博客网 时间:2024/06/16 06:36
在android开发过程中,编写java代码中的常量过一般情况下,我们是定义在string.xml这个文件中。这样修改起来也很方便,而且做国际化也很简单。
这个string.xml的值会被R文件映射,所以可以看到R文件全是定义为int类型,就像是一个地址指引一样。
获取string.xml文件里面的值有几个不同的地方。
1. 在AndroidManifest.xml与layout等xml文件里:
- android:text="@string/resource_name"
2.在activity里:
- 方法一:this.getString(R.string.resource_name);
- 方法二:getResources().getString(R.string.resource_name);
3在其他java文件(必须有Context或pplication)
- context.getString(R.string.resource_name);
- application.getString(R.string.resource_name);
0 0
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- Android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- android获取string.xml的值
- Myeclipse中改变变量、方法等的颜色
- 用perl读写Excel表格
- 超级网址汇总
- android 通过UncaughtExceptionHandler 捕获RuntimeException,并将捕获到的信息上传到友盟
- python的按位运算
- android获取string.xml的值
- HDU_1061_RightmostDigit
- Roman to Integer
- 【独立开发者er Cocos2d-x实战 011】Cocos2dx 3.x命令行生成APK详解
- 跟着9张思维导图学习Javascript
- Using Undo/Redo with Item Views
- Activity统一退出
- sublime学习之--批量在多行首位添加代码
- mac下安装opencv