如果我只有一个组,则在ExpandableListView中。我想隐藏那个组,只有组的数据显示。请帮我如何隐藏Android中的ExpandableListView中的组
9
A
回答
1
设置父IEW vlayout PARAMS hieght在你BaseExpandableListAdapter,这样可以隐藏你父
11
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;
}
如果你想证明你有从getGroupView方法以编程方式添加一个ImageView的一组指标
expandableListView.expandGroup(GROUP_ID);
4):
3)呼叫expandGroup为组你没有显示条组。查看这篇博客文章了解隐藏/显示组指示器的更多信息:Hiding group indicator for empty groups
9
我有同样的问题,这解决了我的问题。 在Listview的适配器中,将以下内容添加到getGroupView。
if (groupPosition == 0) {
convertView = layoutInflater.inflate(R.layout.blank_layout, null);
} else {
convertView = layoutInflater.inflate(R.layout.group_indicator_cell,null);
}
这将使列表的第0组空白。
其中空白布局是布局,其中一些视图里面有layout_height = 0dp。 它的工作原理!
+0
我刚才试过这个,它确实有效,但它对可扩展列表中的其余可见组导致了一些奇怪的行为。尽管如此,聪明的解决方案! – LargeGlasses
2
而不是返回一个空的布局,我穿过布局中的所有孩子,并在没有数据时调用view.setVisibility(View.Gone)
。
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
LinearLayout lo;
if (convertView != null) {
lo = (LinearLayout) convertView;
} else {
lo = (LinearLayout) mLayoutInflater.inflate(R.layout.list_item_group_header, parent, false);
}
int visibility = mData.size() == 0 ? View.GONE : View.VISIBLE;
for (int i = 0; i < lo.getChildCount(); i++) {
lo.getChildAt(i).setVisibility(visibility);
}
return lo;
}
相关问题
- 1. 隐藏ExpandableListView的组标题
- 2. ExpandableListView中的隐藏按钮
- 3. Android:在ExpandableListView中隐藏子分隔符
- 4. 如何完全隐藏ExpandableListView的groupIndicator?
- 5. Android中的ExpandableListView
- 6. xamarin andriod ExpandableListView:从组中删除或隐藏子视图
- 7. 如何隐藏Android中的布局
- 8. 如何隐藏SD卡中的Android
- 9. 如何隐藏CQ5中的parsys组件?
- 10. 如何隐藏行组中的一行?
- 11. Android:获取ExpandableListView中的组数量?
- 12. ExpandableListView - 隐藏无子女组的指示灯
- 13. 隐藏Grouptree中的空组
- 14. 在Android ExpandableListView中,如何更改两个组之间的边距
- 15. 如何在Android中使用“隐藏类”?
- 16. 如何在android中隐藏导航栏?
- 17. 如何在Xamarin.Forms中隐藏Android ActionBar?
- 18. 隐藏分隔线没有隐藏childDivider on ExpandableListView
- 19. 如何从组中隐藏webpart?
- 20. 如何在VBA中隐藏多组列?
- 21. 如何隐藏一组UI组件的
- 22. 隐藏的Android
- 23. 如何隐藏JavaScript中的单独数组中的JSON数据?
- 24. Android中的不同值ExpandableListView
- 25. ExpandableListView中的Android分隔符
- 26. Android ExpandableListView在bindChildView中获取组编号
- 27. 如何隐藏标题Android
- 28. 如何在Android中隐藏图库中的图像?
- 29. 如何在android中的listview中隐藏和显示图像?
- 30. 如何在android中的mapView中隐藏灰色/白色区域
我试图 parent.getLayoutParams()高度= 0。 parent.invalidate();我试过了: parent.setLayoutParams 但它启动ClassCastException :( 你真的试过这个或你猜对了吗? – Giorgio