您的位置:首页 > 产品设计 > UI/UE

android 获取values String

2015-08-19 10:03 351 查看
http://developer.android.com/guide/topics/resources/string-resource.html

文件名:

res/values/filename.xml

文件内容:

<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="hello">Hello!</string>
</resources>
代码使用:

String string = getString(R.string.hello);

如果是


String Array 

 
R.array.string_array_name






<?xml version="1.0" encoding="utf-8"?>
<resources>
<string-array name="planets_array">
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
</string-array>
</resources>
使用:

Resources res = getResources();
String[] planets = res.getStringArray(R.array.planets_array);
原文地址:http://blog.csdn.net/aikongmeng/article/details/41890163
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: