标签:android http io ar sp for 文件 on cti
为一组view设置相对应的一组图片资源时用到数组。
1.在string.xml中定义.pic1234是已放入drawable文件夹下的图片。
<string-array name="main_tab_images">
<item>@drawable/pic1</item>
<item>@drawable/pic2</item>
<item>@drawable/pic3</item>
<item>@drawable/pic4</item>
</string-array>
2.获取图片的id
TypedArray ar = context.getResources().obtainTypedArray(R.array.actions_images);
int len = ar.length();
int[] resIds = new int[len];
for (int i = 0; i < len; i++){
resIds[i] = ar.getResourceId(i, 0);//资源的id
}
http://stackoverflow.com/questions/6945678/android-storing-r-drawable-ids-in-xml-array
标签:android http io ar sp for 文件 on cti
原文地址:http://www.cnblogs.com/chrono/p/4082014.html