博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
调用字符串资源的几种方法
阅读量:7282 次
发布时间:2019-06-30

本文共 614 字,大约阅读时间需要 2 分钟。

字符串资源的定义

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

 

----以上转自: http://www.ixueyun.com/community/forum-redirect-tid-1209-goto-lastpost.html

转载于:https://www.cnblogs.com/newlooker/archive/2013/04/05/3001708.html

你可能感兴趣的文章
【分享】免费建立自己的站点
查看>>
表单的验证:客户端验证和服务器端验证
查看>>
c++ 类初始化
查看>>
How to deal with the problem '<' in OpenERP's view file
查看>>
Linux下方便的块设备查看工具lsblk
查看>>
C#制作在线升级程序
查看>>
Android项目Tab类型主界面大总结 Fragment+TabPageIndicator+ViewPager
查看>>
SSHD配置
查看>>
关于开源的RTP——jrtplib的使用
查看>>
mac osx voice over的使用
查看>>
【Tools】maven安装
查看>>
每日一句(2014-9-11)
查看>>
【BZOJ】1665: [Usaco2006 Open]The Climbing Wall 攀岩(spfa)
查看>>
最长上升(不下降)子序列(详细,转)
查看>>
EF 6 调用存储过程时返回多结果集和OUTPUT参数问题
查看>>
oracle调优 浅析关联设计
查看>>
@功能的逻辑判断(原创)
查看>>
java异常处理
查看>>
SQL Server 的三种用户自定义函数
查看>>
nodejs文件操作笔记
查看>>