展开扩展列表视图中的所有儿童 [英] Expand all children in expandable list view

查看:90
本文介绍了展开扩展列表视图中的所有儿童的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想扩大所有儿童,而扩展列表视图填充。 目前,我的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;
}

格鲁克!

这篇关于展开扩展列表视图中的所有儿童的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆