如何处理Android SimpleExpandableListAdapter条目选择
我使用 SimpleExpandableListAdapter 类型在 Android 应用程序中创建了一个可扩展列表。 但我完全不知道如何在选择/单击子条目之一时检测事件。
我已经尝试了所有常见的 OnClickListener/OnChildClickListener 等,但似乎无法找到(通过实验或半小时谷歌搜索)正确的处理程序例程应该是什么。
非常感谢任何帮助。
I have created an expandable list in my Android application using the SimpleExpandableListAdapter type.
But I'm at a complete loss as to how I detect events when one of the child entries has been selected/clicked.
I've tried all the usual OnClickListener/OnChildClickListener etc, but can't seem to find (by experimentation, or half an hour googling) what the correct handler routines should be.
Any help greatfully appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它应该是:
虽然,听起来你尝试过这个... ExpandableListView .OnChildClickListener 说这实际上就是这样做的方法。
另外,您是否为 ListAdapter 定义了方法 allItemsAreEnabled() 和/或 isEnabled() ?您不应该这样做,但也许它们当前已定义并返回错误的值?
It should be:
Though, it sounds like you tried this... ExpandableListView.OnChildClickListener says that it is, in fact, the way to do it.
Also, have you defined the methods allItemsAreEnabled() and/or isEnabled() for your ListAdapter? You shouldn't have to, but maybe they are currently defined and returning the wrong values?
另外...
如果您碰巧使用扩展 BaseExpandableListAdapter 的类,那么它们是默认实现的方法,您必须为其设置返回布尔值。
默认情况下,此方法返回 false,交换为 true(如果是这种情况),并且您的 OnChildClickListener 应该开始正确解析。
Also...
If you happen to be using a class that extends BaseExpandableListAdapter then their is a default implemented method you'll have to set the return boolean for.
By default this method is returning false, swap to true(if this is the case) and your OnChildClickListener should start resolving correctly.