正确的解法:
String mess = getResources().getString(R.string.mess_1);
另外一种:
you can simplify that to 
this.getString(R.string.some_id) 
关键点android 字符串比较,android 截取字符串,android 字符串,android 字符串数组,androidpost字符串,android 字符串转换,

字符串资源的定义

文件路径: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)

更多相关文章

  1. Android(安卓)journey 2 @Android系统框架
  2. Android(安卓)Studio 解决Fetching android sdk component infor
  3. Android(安卓)热修复方案Tinker(四) 资源补丁加载
  4. Android(安卓)中从res/values/strings.xml中读取具体的字符串的
  5. 【Demo 0001】Android(安卓)程序结构
  6. 【转】Android(安卓)xml资源文件中@、@android:type、@*、?、@+含
  7. Android(安卓)xml资源文件中@、@android:type、@*、?、@+含义和区
  8. Android资源汇总贴
  9. Android(安卓)xml资源文件中@、@android:type、@*、?、@+含义和区

随机推荐

  1. android RelativeLayout 布局属性详解
  2. Activity属性
  3. Android Log 机制
  4. android studio中用svn来管理项目
  5. Android--ListView滚动条样式
  6. ok6410 android driver(5)
  7. Android新技术
  8. Android中使用Kotlin实现一个简单的登录
  9. Android官方架构组件介绍之LifeCycle
  10. [android]fmodex在某些android设备上声音