[Android]调用字符串资源的方法
2011-06-09 10:46
411 查看
字符串资源的定义
文件路径:res/values/strings.xml
字符串资源定义示例:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
</resources>
字符串资源的调用
在 Layout XML 调用字符串资源:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
在 Activity 获取字符串资源:
this.getString(R.string.hello)
从 Context 获取字符串资源:
context.getString(R.string.hello)
从 Application 获取字符串资源:
application.getString(R.string.hello)
参考:
String Resources
作者:黎波
博客:http://bobli.cnblogs.com/
日期:2011年6月4日
文件路径:res/values/strings.xml
字符串资源定义示例:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
</resources>
字符串资源的调用
在 Layout XML 调用字符串资源:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
在 Activity 获取字符串资源:
this.getString(R.string.hello)
从 Context 获取字符串资源:
context.getString(R.string.hello)
从 Application 获取字符串资源:
application.getString(R.string.hello)
参考:
String Resources
作者:黎波
博客:http://bobli.cnblogs.com/
日期:2011年6月4日
相关文章推荐
- android 调用字符串资源 res/values/strings.xml 的几种方法
- [Android]调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- Android 调用资源字符串的几种方法
- Android中调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- [Android]调用字符串资源的方法
- android从strings资源文件获取,并拼接字符串方法
- Android-调用本地方法将小写字符串转成大写字符串/NDK-JNI开发实例(四)
- 调用 Android系统资源的方法
- android 读取资源字符串的 方法
- Android中调用Paint的measureText()方法取得字符串显示的宽度值
- android 读取资源字符串的 方法
- Android字符串资源文件format方法使用实例
- android 隐藏API显式调用以及内部资源使用方法
- 调用字符串资源的几种方法
- 我的Android进阶之旅------>Android字符串资源中的单引號问题error: Apostrophe not preceded by 的解决的方法
- Android-使用C++实现调用本地方法返回字符串显示在界面上/NDK-JNI开发实例(八)