从Java Android代码访问string.xml资源文件 [英] Access string.xml Resource File from Java Android Code
本文介绍了从Java Android代码访问string.xml资源文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从Android Activity类
访问 res/values/string.xml
资源文件中的值?
How do you access the values in the res/values/string.xml
resource file from the Android Activity class
?
推荐答案
将此代码放入 res/values/string.xml
<string-array name="planet">
<item>Mercury</item>
<item>Venus</item>
<item>Earth</item>
<item>Mars</item>
</string-array>
此代码将放置在 res/layout/main.xml
中,并删除 main.xml
中存在的默认小部件.
This code to be placed in res/layout/main.xml
and remove default widgets present in main.xml
.
<ListView android:id="@+id/planet"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:entries="@array/planet"/>
</LinearLayout>
这篇关于从Java Android代码访问string.xml资源文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文