android 读取资源字符串的 方法
来源:互联网 发布:知乎4.7怎么不能提问 编辑:程序博客网 时间:2024/06/16 10:35
字符串资源的定义
文件路径:res/values/strings.xml
字符串资源定义示例:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
</resources>
<resources>
<string name="hello">Hello!</string>
</resources>
字符串资源的调用
在 Layout XML 调用字符串资源:
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="@string/hello" />
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日
博客:http://bobli.cnblogs.com/
日期:2011年6月4日
0 0
- android 读取资源字符串的 方法
- android 读取资源字符串的 方法
- android读取资源文件的方法
- C# 读取.resx资源文件内字符串的方法
- [Android]调用字符串资源的方法
- [Android]调用字符串资源的方法
- Android读取工程内 资源文件的两种方法
- 解析Android资源文件及他们的读取方法详解
- 解析Android资源文件及他们的读取方法详解
- 解析Android资源文件及他们的读取方法详解
- 读取资源文件的方法
- Android中资源的读取
- [Android]调用字符串资源的几种方法
- android字符串资源String中插入某些字符的方法
- Android中调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- HA
- jQuery学习笔记之 Dom 操作 append、prepend、after、before、appendTo
- Windows下android开发环境搭建
- python数据转换
- Android中Button.setClickable(false)不起作用
- android 读取资源字符串的 方法
- linux下多线程的调试
- spring下载方法
- SpringMVC Controller 介绍
- 归并排序java实现
- Mysql中show status的字段解释
- MKMapView放大缩小事件
- iOS 本地文件
- POJ 3176--Cow Bowling