Reputation: 16196
I have develop ExpandableListView perfectly.
In My ExpandableListView five groups are there. load first time then collapse all five group. it is default.
now my question is load first time expandablelistview at that time 2 groups are expand and other 3 groups are collapse.
so please guide me how to do?
Upvotes: 43
Views: 55669
Reputation: 39
Perfect solution for expanding expandable listview
ExpandableListAdapter expandableListAdapter;
ExpandableListView expandableListView;
expandableListView.expandGroup(0);
expandableListView.expandGroup(1);
expandableListAdapter.notifyDataSetChanged();
Upvotes: 1
Reputation: 2454
This is a perfect solution, it will increase automatically
ExpandableListView elv = (ExpandableListView) findViewById(R.id.elv_main);
elv.setAdapter(adapter);
for(int i=0; i < adapter.getGroupCount(); i++)
elv.expandGroup(i);
but this is based on the item positions
ExpandableListView Exlist;
Exlist.expandGroup(0);// first item of listview
Exlist.expandGroup(1);//second item of listview
Upvotes: 6
Reputation: 3277
I built this snippet based off Nikhil's answer. Thought others might find it useful as well. Only works if you are using BaseExpandableListAdapter. elv
ExpandableListView elv = (ExpandableListView) findViewById(R.id.elv_main);
elv.setAdapter(adapter);
for(int i=0; i < adapter.getGroupCount(); i++)
elv.expandGroup(i);
Upvotes: 78
Reputation: 16196
Now I got solution and it will work perfectly.. Please use this..
ExpandableListView Exlist;
Exlist.expandGroup(0);
Exlist.expandGroup(1);
Upvotes: 115