I would like to expand all children while the expandable list view is populated. Currently my code looks like this:
ExpandableListView listView = (ExpandableListView) findViewById(R.id.view); int count = viewAdapted.getGroupCount(); for (int position = 1; position <= count; position++) listView.expandGroup(position - 1);
which is pretty ugly. Is there a nicer way to do this?
A view that shows items in a vertically scrolling two-level list. This differs from the ListView by allowing two levels: groups which can individually be expanded to show its children. The items come from the ExpandableListAdapter associated with this view.
To do this, use the Expand and Collapse actions of the Android ExpandableList object that corresponds to the tested expandable list. You can expand or collapse all the groups of the list by setting the Group parameter to -1.
You can expand it in getGroupView in your custom adapter:
@Override public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) { View v = super.getGroupView(groupPosition, isExpanded, convertView, parent); ExpandableListView mExpandableListView = (ExpandableListView) parent; mExpandableListView.expandGroup(groupPosition); return v; }
Gluck!
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