Collapse all group except selected group in expandable listview android

后端 未结 8 995
故里飘歌
故里飘歌 2020-12-23 09:20

I\'m developing android application using expandable list view. Actually what I need is, I\'m listing group, which contains child.

If I select an unexpandable group

8条回答
  •  忘掉有多难
    2020-12-23 09:32

    Use this code this will work

    expandableList.setOnGroupExpandListener(new OnGroupExpandListener() {
        int previousItem = -1;
    
        @Override
        public void onGroupExpand(int groupPosition) {
            if(groupPosition != previousItem )
                expandableList.collapseGroup(previousItem );
            previousItem = groupPosition;
        }
    });
    

提交回复
热议问题