我在Android上使用ExpandableListView
。我必須通過點擊孩子來調用不同的活動。每個孩子都必須指導我參加新的活動。請告訴我,我該怎麼做。來自onChildClick的Statrt newActivity expandableListView
我的代碼是有點像:
list.setOnChildClickListener(new OnChildClickListener() {
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
// TODO Auto-generated method stub
ExpandableListAdapter adap = parent.getExpandableListAdapter();
int gp = (int) adap.getGroupId(groupPosition);
int cp = (int) adap.getChildId(groupPosition, childPosition);
if (gp == 0) {
switch (cp) {
case 0:
Intent intent = new Intent(getApplicationContext(),
Test11.class);
break;
case 1:
Intent intent = new Intent(getApplicationContext(),
Test12.class);
}
} else if (gp == 1) {
switch (cp) {
case 0:
Intent intent = new Intent(getApplicationContext(),
Test21.class);
break;
case 1:
Intent intent = new Intent(getApplicationContext(),
Test22.class);
break;
}
}
return true;
}
});
什麼是你現在所面臨的困難? –
當我點擊子節點應用程序意外停止 –