我创建了一个带有可扩展列表视图的导航抽屉。我有两个组。(Group-1,Group-2)例如,当我单击(group-1,index-2)时,它的视图被突出显示,但(group-2,index-1)视图也被突出显示。这是我的孩子点击监听器:
// Listview on child click listener
expListView.setOnChildClickListener(new OnChildClickListener() {
@Override
public boolean onChildClick(ExpandableListView parent, View v,
int groupPosition, int childPosition, long id) {
Toast.makeText(
getApplicationContext(),
listDataHeader.get(groupPosition)
+ " : "
+ listDataChild.get(
listDataHeader.get(groupPosition)).get(
childPosition), Toast.LENGTH_SHORT)
.show();
int index = parent.getFlatListPosition(ExpandableListView.getPackedPositionForChild(groupPosition, childPosition));
parent.setItemChecked(index, true);
mDrawerLayout.closeDrawer(expListView);
return false;
}
});
我为什么要这样做?为什么两个组项目都被突出显示?