Android -- 在xml文件中定义drawable数组
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();
我是天王盖地虎的分割线
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。