如何在Android中的ExpandableListView中隐藏组

在ExpandableListView中,如果我只有一个组.我想隐藏该组,只有组的数据显示.请帮帮我

解决方法

1)隐藏组指示符:
android:groupIndicator="@android:color/transparent"

2)为您想要为空的组返回一个空的FrameLayout,如下所示:

@Override
public View getGroupView(int groupPosition,boolean isExpanded,View convertView,ViewGroup parent) {

    //By default the group is hidden
    View view = new FrameLayout(context);

    String groupTitle = getGroup(groupPosition).toString();

    //in case there's more than one group and the group title is not empty then show a TextView within the group bar
    if(getGroupCount() > 1 && !groupTitle.isEmpty()) {

        view = getGenericView();
        ((TextView)view).setText(groupTitle);
    }

    return view;

}

3)呼叫expandGroup为不显示组组的组:

expandableListView.expandGroup(GROUP_ID);

4)如果要显示组指示符,则必须通过getGroupView方法以编程方式添加ImageView.查看这篇博文,了解隐藏/显示组指标的更多信息:Hiding group indicator for empty groups

相关文章

Android性能优化——之控件的优化 前面讲了图像的优化,接下...
前言 上一篇已经讲了如何实现textView中粗字体效果,里面主要...
最近项目重构,涉及到了数据库和文件下载,发现GreenDao这个...
WebView加载页面的两种方式 一、加载网络页面 加载网络页面,...
给APP全局设置字体主要分为两个方面来介绍 一、给原生界面设...
前言 最近UI大牛出了一版新的效果图,按照IOS的效果做的,页...