1.array int型数组调用
<integer-array name="exercising_pic">
<item>@drawable/kung_fu_0</item>
<item>@drawable/kung_fu_1</item>
<item>@drawable/kung_fu_2</item>
<item>@drawable/kung_fu_3</item>
<item>@drawable/kung_fu_4</item>
<item>@drawable/kung_fu_5</item>
<item>@drawable/kung_fu_6</item>
<item>@drawable/kung_fu_0</item>
<item>@drawable/kung_fu_1</item>
<item>@drawable/kung_fu_2</item>
<item>@drawable/kung_fu_3</item>
<item>@drawable/kung_fu_4</item>
<item>@drawable/kung_fu_5</item>
<item>@drawable/kung_fu_6</item>
<item>@drawable/kung_fu_3</item>
<item>@drawable/kung_fu_4</item>
<item>@drawable/kung_fu_5</item>
<item>@drawable/kung_fu_6</item>
</integer-array>
TypedArray array = getResources().obtainTypedArray(R.array.exercising_pic);
int len = array.length();
itemPic = new int[len];
for (int i = 0; i < len; i++) {
itemPic[i] = array.getResourceId(i, 0);
}
2. listview 获取数据
mCustomizeExerciseingListView.setOnItemClickListener(new AdapterView.OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
TextView itemName = (TextView) view.findViewById(R.id.item_name);
Bundle bundle=new Bundle();
bundle.putString("item_name",itemName.getText().toString());
startActivity(NewExercisingActivity.class, bundle);
}
});
待续。