禁用崩溃ExpandableListView的
问题描述:
ExpandableListView
的默认行为是可折叠组的头被点击时。是否有可能以prevent这种情况的发生?
The default behavior of ExpandableListView
is to collapse a group when its header is clicked. Is it possible to prevent this from happening?
我已经试过:
- 设置
OnTouchListener
的名单上。这干扰了滚动。 - 在列表上设置一个
OnGroupClickListener
(在的onCreate()
)。这适用于所有点击的在的第一个。
- Setting
OnTouchListener
on the list. This interferes with scrolling. - Setting an
OnGroupClickListener
on the list (inonCreate()
). This works for all clicks after the first.
有没有其他人做到了这一点?为什么会在 OnGroupClickListener
错过了第一次点击?
Has anyone else accomplished this? Why might the OnGroupClickListener
miss the first click?
在此先感谢您的建议。
答
看来问题不得不与那里是在组头既是一个聚焦元素和 OnGroupClickListener
设置。卸下听者解决我的问题。
It seems the problem had to do with there being both a focusable element in the group header and an OnGroupClickListener
set. Removing the listener solved my problem.