我正在使用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,然后像你提到的那样限制。 –