当我扩展一个新组时,我可以折叠最后一个扩展的组吗?
最佳答案
尝试将其放在ExpandableListAdapter
中,listView
是对ExpandableListView
本身的引用。 lastExpandedGroupPosition
是在ExpandableListAdapter
内部定义的整数成员变量。
@Override
public void onGroupExpanded(int groupPosition){
//collapse the old expanded group, if not the same
//as new group to expand
if(groupPosition != lastExpandedGroupPosition){
listView.collapseGroup(lastExpandedGroupPosition);
}
super.onGroupExpanded(groupPosition);
lastExpandedGroupPosition = groupPosition;
}