您的位置:首页 > 产品设计 > UI/UE

Android 中从res/values/strings.xml中读取具体的字符串的方法

2013-03-29 17:18 441 查看
正确的解法:
[code]String mess = getResources().getString(R.string.mess_1);
另外一种:
you can simplify that to
[code]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)
                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐