I want to make only one item in the parent list expand at a time, my code for the onCreate is currently the following. (It works as I want, But the method to allow only one pare
Easiest approach
You can implement ExpandableListView.OnGroupExpandListener
, in where you run collapseGroup()
for all list groups except the one being clicked. This will do what you want.
expandableList.setOnGroupExpandListener(new OnGroupExpandListener() {
int previousGroup = -1;
@Override
public void onGroupExpand(int groupPosition) {
if(groupPosition != previousGroup)
expandableList.collapseGroup(previousGroup);
previousGroup = groupPosition;
}
});