Question Detail

Show only one child of expandable list at a time android.

6 years ago Views 1683 Visit Post Reply

When I click on ExpandableListView's List Item it open and move on next and click on that also open Now I have two open item Open. But I want when I click on another item last opened auto collapse. How can I do this?  

Thread Reply

Hemant Sharma

- 6 years ago

// Listview GroupExpandListener listener
employeelistexpListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
    int previousGroup = -1;

    public void onGroupExpand(int groupPosition) {
        if(groupPosition != previousGroup)employeelistexpListView.collapseGroup(previousGroup);
        previousGroup = groupPosition;
        if (isopen) {
            isopen = false;
        } else {
            isopen = true;