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, it should expand, after I ll select second group at that time the first group should be collapsed. I did Google, but I couldn't find what I want. Please help me out.
Have the current expanded group position stored in a variable. In onGroupExpanded do the following.
private int lastExpandedPosition = -1; private ExpandableListView lv; //your expandable listview ... lv.setOnGroupExpandListener(new OnGroupExpandListener() { @Override public void onGroupExpand(int groupPosition) { if (lastExpandedPosition != -1 && groupPosition != lastExpandedPosition) { lv.collapseGroup(lastExpandedPosition); } lastExpandedPosition = groupPosition; } });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With