我正在使用ExpandableListView
加上「groups」和「childs」元素。是否有可能禁用擴展一些組元素?我是否需要更改適配器中的某些代碼,或者我應該使用override
onclick
方法嗎?如何禁用expandablelistview中的elemts?
2
A
回答
1
您的ListView使用setOnGroupClickListener
並返回true
上要禁用要花費
這將禁用的第一要素是位置消費
expListView.setOnGroupClickListener(new ExpandableListView.OnGroupClickListener() {
@Override
public boolean onGroupClick(ExpandableListView expandableListView, View view, int i, long l) {
if (i==0){
return true;
}
return false;
}
});
1
對那些不會在點擊時觸發的組標題調用.setClickable(false)。 您的適配器撥打getGroupView
。此方法返回顯示爲組標題的視圖。 如果你不想要這個觀點點擊,撥打.setClickable(false)
@Override
public View getGroupView(int groupPosition, boolean isExpanded, View convertView, ViewGroup parent) {
if (convertView == null) {
LayoutInflater li = LayoutInflater.from(activity);
convertView = li.inflate(<<your header item>>, null);
}
if (isLastGroup)
convertView.setClickable(false);
return convertView;
}
相關問題
- 1. 如何禁用Collapse of ExpandableListView?
- 2. 禁用ExpandableListView的摺疊
- 3. ExpandableListView groupIndicator被禁用了CheckBox
- 4. 在ExpandableListView中禁用高亮顯示
- 5. 如何讓FastScroll使用ExpandableListView?
- 6. ExpandableListView如何實現?
- 7. Android中的ExpandableListView
- 8. iOS中的ExpandableListView
- 9. ExpandableListView中的LinearLayout
- 10. ListView中的ExpandableListView
- 11. 更改HTML elemts風格5
- 12. ExpandableListView如何在片段
- 13. 如何突出一個ExpandableListView
- 14. 如何從ExpandableListView控件中刪除組?
- 15. 如何禁用fabricjs中禁用shift鍵?
- 16. 如何將ExpandableListview左圖標更改爲其他人(android ExpandableListView)
- 17. ExpandableListView
- 18. 如何用HashMap實現ExpandableListView中的過濾器
- 19. 如何用數據庫表中的數據填充ExpandableListView ..?
- 20. 如何刪除ExpandableListView的按鈕?
- 21. 如何完全隱藏ExpandableListView的groupIndicator?
- 22. 如何設置ExpandableListView的二級列表?
- 23. 如何隱藏Android中的ExpandableListView中的組
- 24. javascript chalanging表單elemts數組驗證
- 25. 顯示圖片重疊css elemts
- 26. Web2py添加與表單elemts錶行
- 27. 繼承angularjs在所有子功能elemts
- 28. 使用SQLite中的數據填充ExpandableListView
- 29. Android ExpandableListVIew使用BaseExpandableListAdapter
- 30. 的Android expandablelistview使用凌空
你可以簡單地在視圖上調用'.setClickbale()' –
@ndeokar謝謝你的回答。但是我並不想禁用所有組元素,但是如果您禁用了對組元素的點擊意味着您不想顯示子元素,我想在邏輯上禁用其中的一些 – MrStuff88
?如我錯了請糾正我。你可以重寫onclick,然後像你提到的那樣限制。 –