ExpandableListView 组项上可以同时具有上下文菜单和默认单击行为吗?
ExpandableListView 组项是否可以同时具有上下文菜单和默认单击行为?
我尝试了这个,发现一旦我在包含 ExpandableListView 的活动中覆盖 onCreateContextMenu,组视图将不再响应单击。当(短按)按下时,它们不会突出显示,也不会展开。
Is it possible to have both a context menu and default click behavior on ExpandableListView group items?
I tried this and found that once I overrode onCreateContextMenu in the activity that contained the ExpandableListView, the group views would no longer respond to clicks. They wouldn't highlight when (short) pressed and they wouldn't expand.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是让包含 ExandableListView 的 Activity 知道它应该处理视图的上下文菜单创建。这可以按如下方式完成,最有可能在 Activity 的重写
onCreate
方法中完成:然后,在 Activity 中,确保重写
onCreateContextMenu
,您将在其中配置显示的上下文菜单。The solution is to let the Activity containing the ExandableListView know that it should handle context menu creation for the view. This can be accomplished as follows, most likely in the overridden
onCreate
method of the Activity:Then, in the Activity, be sure to override
onCreateContextMenu
, where you'll configure the context menu that gets shown.