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
I also faced the same problem. But I could solved my problem by the following code:
As I had 4 Headers in my expandable list, based on that i wrote like this
expListView.setOnGroupExpandListener(new OnGroupExpandListener() {
@Override
public void onGroupExpand(int groupPos) {
// TODO Auto-generated method stub
expListView.collapseGroup(groupPos+1);
expListView.collapseGroup(groupPos-1);
expListView.collapseGroup(groupPos-2);
expListView.collapseGroup(groupPos+2);
expListView.collapseGroup(groupPos+3);
expListView.collapseGroup(groupPos-3);
}
});`
Get ExpendableListView
and then override the following method - setOnGroupExpandListener
expandableListView = (ExpandableListView) findViewById(R.id.exp_listview);
expandableListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
int previousItem = -1;
@Override
public void onGroupExpand(int groupPosition) {
if (groupPosition != previousItem)
expandableListView.collapseGroup(previousItem);
previousItem = groupPosition;
}
});