android中有 <array /> <string-array /> <integer-array />
获取res目录下资源的方法
Resources res = this.getResources();
res.getStringArray(int id);
//获取图片的方法
res.getDrawable(int id);
// 在一个应用下的所以activity中都是同一个.getResources
因为继承了同一个context接口
在java中获取数组的代码:
int[] getStringArray(int id);
TypedArray obtainTypedArray(int id);
//TypedArray 代表通用型数组
在resources 下书写数组
<resources>
1 .定义一个 drawabe数组
<array name= "demo1">
<item>@color/c1</item>
<item>@color/c2</item>
</array>
2.定义一个 字符串数组
<string-array name= "demo1">
<item>@string/c1</item>
<item>@string/c2</item>
</string-array>
3.定义一个 字符串数组
<string-array name= "demo1">
<item>早上吃什么</item>
<item>我饿了</item>
</string-array>
</resources>