[Android]调用字符串资源的几种方法
来源:互联网 发布:风衣 孙燕姿 知乎 编辑:程序博客网 时间:2024/05/17 19:20
[Android]调用字符串资源的几种方法
字符串资源的定义
文件路径: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日
- [Android]调用字符串资源的几种方法
- Android中调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- [Android]调用字符串资源的几种方法
- android 调用字符串资源 res/values/strings.xml 的几种方法
- [Android]调用字符串资源的方法
- [Android]调用字符串资源的方法
- 安卓ImageView的几种资源调用方法
- Android获取资源文件的几种方法
- Android中获取资源文件的几种方法
- Android 后台线程调用前台线程的几种方法
- Android延时执行调用的几种方法
- Android延时执行调用的几种方法
- android webView调用js函数的几种方法
- Android Toast的几种简单调用方法
- Android延时执行调用的几种方法(转)
- Android延时执行调用的几种方法
- java网络编程笔记
- 通过按钮控件实现MDI新建子窗口(MFC自动生成的视图、文档、子框架共用)
- 可变参数列表(va_list,va_arg,va_copy,va_start,va_end)
- 【热门收藏啦】Windows Phone开发人员必看资料
- 林伟强:wordpress利于SEO优化的十三个插件
- [Android]调用字符串资源的几种方法
- 修改hMailServer管理密码
- Web工程师必备的43款可视化工具
- Android中常常使用shape来定义控件的一些显示属性,今天看了一些shape的使用,对shape有了大体的了解,稍作总结: 先看下面的代码: <shape>
- 机器视觉开发思路
- Oracle开发之:窗口函数
- Gson简要使用笔记
- 字符串去掉重复的值
- google map api v3