Question Detail

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

- 1 years ago

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

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