如果我只有一個組,則在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