我想扩大所有儿童,而扩展列表视图填充。 目前,我的code是这样的:
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);
这是pretty的丑陋。 有没有更好的方式来做到这一点?
which is pretty ugly. Is there a nicer way to do this?
您可以在getGroupView在自定义的适配器展开它:
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;
}
格鲁克!