我想知道如何使用 setonItemclick 侦听器方法获取可扩展列表视图的子值。下面给出了我的代码,但单击事件无法正常工作。
mExpandableListView.setOnItemClickListener(new OnItemClickListener() {
@Override
public void onItemClick(AdapterView<?> parent, View v, int groupPosition,
long id) {
// TODO Auto-generated method stub
int itemType = ExpandableListView.getPackedPositionType(groupPosition);
Log.i("item type",""+itemType);
if ( itemType == ExpandableListView.PACKED_POSITION_TYPE_CHILD) {
childPosition = ExpandableListView.getPackedPositionChild(id);
groupPosition = ExpandableListView.getPackedPositionGroup(id);
Log.i("child",""+ childPosition);
Log.i("child Group",""+ groupPosition);
} else if(itemType == ExpandableListView.PACKED_POSITION_TYPE_GROUP) {
groupPosition = ExpandableListView.getPackedPositionGroup(id);
Log.i("Group",""+ groupPosition);
}
}
});