我正在使用ExpandableListView
Android。我必须通过单击孩子来调用不同的活动。每个孩子都必须指导我进行新的活动。请告诉我我该怎么做。
我的代码有点像:
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;
}
});