在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