Xml
<string-array name="images">
<item>@drawable/image1</item>
<item>@drawable/image2</item>
<item>@drawable/image3</item>
<item>@drawable/image4</item>
<item>@drawable/image5</item>
<item>@drawable/image6</item>
</string-array>
<array name="images">
<item>@drawable/image1</item>
<item>@drawable/image2</item>
<item>@drawable/image3</item>
<item>@drawable/image4</item>
<item>@drawable/image5</item>
<item>@drawable/image6</item>
</array>
Java
TypedArray ar = context.getResources().obtainTypedArray(R.array.images);
int len = ar.length();
int[] resIds = new int[len];
for (int i = 0; i < len; i++)
resIds[i] = ar.getResourceId(i, 0);
ar.recycle();
我是天王盖地虎的分割线