Android 实现添加本地数组在Res/values下的xml文件

来源:互联网 发布:line安卓版 无网络 编辑:程序博客网 时间:2024/05/17 17:55

把相应的数据放到Res/values文件夹的(名字可以自定义)array.xml文件里

1. String数组

<?xml version="1.0" encoding="utf-8"?><resources>    <string-array name="yinxiao">        <item>混合</item>        <item>流行</item>           </string-array>
</resources>
使用:
Resources res =getResources();String[] city=res.getStringArray(R.array.yinxiao);
可取得"yinxiao"下的所有item数据。
2.其他类型

整型数组

<integer-array name="voice">  <item>50</item>  <item>80</item> </integer-array></resources>  

 

Drawable 数组

<array name="sample_images">    <item>@drawable/title</item>    <item>@drawable/logo</item>    <item>@drawable/icon</item></array>

 

color 数组

<array name="sample_colors">    <item>#FFFF0000</item>    <item>#FF00FF00</item>    <item>#FF0000FF</item></array>


阅读全文
0 0
原创粉丝点击