转自:http://www.cnblogs.com/bobli/archive/2011/06/04/2072942.html

字符串资源的定义

文件路径:res/values/strings.xml

字符串资源定义示例:

<?xmlversion="1.0"encoding="utf-8"?>
<resources>
<stringname="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)

更多相关文章

  1. 小米1出现的资源文件找不到问题!
  2. 算法 - 给出一个字符串str,输出包含两个字符串str的最短字符串,如
  3. 反编译APK 得到JAVA代码和资源文件源码
  4. java中 16进制字符串 与普通字符串 与 byte数组 之间的转化
  5. 忽略转义字符时拆分字符串
  6. 使用字符串参数调用AndroidJni静态方法。
  7. java中匹配字符串中的中文字符(含中文标点的)
  8. String字符串的应用
  9. java 正则表达式查找某段字符串中所有小写字母开头的单词并统计

随机推荐

  1. Android 面试必备 - JVM 及 类加载机制
  2. Android 5.0 API新增和改进
  3. Android Property System | Android属性
  4. Android腾讯微薄客户端开发教程汇总
  5. Android(安卓)通过NTP服务器自动获取时间
  6. ImageView---属性android:background与andro
  7. Android开发工具下载地址
  8. android(2)——Structure of an Android
  9. vue.js的h5页面与android(WebViewJavascr
  10. ffmpeg htc