只展开一组,重写ExpandableListView的一个监听器setOnGroupExpandListener这个是监听,展开时的回调
具体代码:
int tagPosition=0;
/**
* 点击有组展开时回调
*/
expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPosition) {
if(tagPosition!=groupPosition&&expandableListView.isGroupExpanded(tagPosition)) {
expandableListView.collapseGroup(tagPosition);
}
tagPosition=groupPosition;
}
});
源码下载
https://download.csdn.net/download/zhaihaohao1/10479130