[Android]调用字符串资源的几种方法
来源:互联网 发布:阿里云tts 编辑:程序博客网 时间:2024/05/19 09:17
字符串资源的定义
文件路径: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
阅读全文
0 0
- [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延时执行调用的几种方法
- centos 7的防火墙命令
- 24、C#:按钮的属性和事件
- java基础——collections总结
- 数据倾斜
- Kettle定时执行(ETL工具)
- [Android]调用字符串资源的几种方法
- 欢迎使用CSDN-markdown编辑器
- MySQL日期格式化函数
- 《Spring Boot in Action》【1. 起步】
- centos卸载docker
- 阿里云批量计算心得
- android 更新api current.txt
- BZOJ 3252: 攻略 贪心 树链剖分
- 服务器安全管理总结