Chinaunix首页 | 论坛 | 博客
  • 博客访问: 190493
  • 博文数量: 47
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 470
  • 用 户 组: 普通用户
  • 注册时间: 2014-06-18 12:09
个人简介

be a happy lazy and fat cat

文章分类
文章存档

2017年(1)

2016年(5)

2015年(22)

2014年(19)

我的朋友

分类: Android平台

2014-12-03 15:20:47

获取string.xml文件里面的值有几个不同的地方。

1.在AndroidManifest.xml与layout等xml文件里:

android:text="@string/resource_name" 

  

2.在activity里:

方法一:this.getString(R.string.resource_name);  

方法二:getResources().getString(R.string.resource_name); 

 

3.在其他java文件(必须有Context或pplication)

方法一:context.getString(R.string.resource_name); 

方法二: application.getString(R.string.resource_name);
阅读(1581) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~