If you have "ExpandableListView" and show only one child of expandable Listview at a time, then below is the code for it.
"groupPosition" will return the open group id. So when I expand the other group then open group will collapse.
expendListView.setOnGroupExpandListener(new ExpandableListView.OnGroupExpandListener() {
int previousGroup = -1;
@Override
public void onGroupExpand(int groupPosition) {
if(groupPosition != previousGroup)
expendListView.collapseGroup(previousGroup);
previousGroup = groupPosition;
}
});
"groupPosition" will return the open group id. So when I expand the other group then open group will collapse.
You can also expand specific item of "ExpandableListView" by applying following code:
expendListView.expandGroup(i);
Thanks its hepled lot.....
ReplyDelete