typedArray.getIndexCount()为什么返回总是0啊
typedArray.getIndexCount()为什么返回总是0啊?
public class PlayActivity extends Activity {
private ListView play_listview;
private PlayAdapter pAdapter;
private List<ViewItem> list;
@Override
protected void onCreate(Bundle bundle) {
super.onCreate(bundle);
setContentView(R.layout.play_activity);
play_listview = (ListView) findViewById(R.id.play_listview);
pAdapter = new PlayAdapter(this, getData());
play_listview.setAdapter(pAdapter);
}
//添加数据
public List<ViewItem> getData() {
list = new ArrayList<ViewItem>();
TypedArray typedArray = null;
typedArray = getResources().obtainTypedArray(R.array.pic_johanna); // pic_johanna是一组图片R资源的数组。
final int a = typedArray.getIndexCount(); //typedArray.getIndexCount()为什么返回总是0啊
int b = 10;
for (int i = 0; i < 20; i++) {
ViewItem item = new ViewItem();//这个必须在这里new 不然 数据都是一样的
if (i % 3 == 0) {
item.type = 0;
} else {
item.type = 1;
}
item.address = null;
item.name = "wang" + a;
list.add(item);
}
return list;
}
}