上下文操作栏与工具栏操作搞乱 [英] Contextual Action Bar messing with Toolbar actions

查看:289
本文介绍了上下文操作栏与工具栏操作搞乱的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用应用程序兼容性V7和支持设计库。在我的活动是有规律的工具栏,其中有三个操作按钮(RM1,RM2,RM3):

I'm using appcompat v7 and the support design libraries. In my activity there is a regular toolbar, which has three action buttons (RM1, RM2, RM3):

_____________________________________
                         RM1 RM2 RM3 |
_____________________________________|  

而当有些项目是长期的点击列表中的一个上下文操作栏(CAB)显示,而不是常规的工具栏。我的出租车有一个单一的动作(CM)。

And when some items are long-clicked in a list, a contextual action bar (CAB) is shown instead of the regular toolbar. My CAB has a single action (CM).

_____________________________________
                                  CM |
_____________________________________|  

在上下文动作栏(CAB)被激活,它隐藏的常规工具栏。在如果我点击上下文菜单(CM)在这一点上,一切正常。但由于某些原因,如果我点击在空的空间的CM的左侧,常规菜单RM1和RM2被示出,尽管常规工具栏被由CAB隐藏。 RM1和RM2图标时,CAB是活动显然没有显示,但单击处理仍然存在,他们被解雇,即使常规工具栏被隐藏。该CAB是不是拦截的点击,除非它在单击点的动作。如果我点击了CM,这是正确处理:未显示RM,因为这个按钮是完全CM菜单下

When the contextual action bar (CAB) is activated, it hides the regular toolbar. At this point if I click on the contextual menu (CM), everything is ok. But for some reason, if I click over the empty space to the left of CM, the regular menus RM1 and RM2 are shown, despite the regular toolbar being hidden by the CAB. RM1 and RM2 icons are obviously not shown when the CAB is active, but the click handlers are still in place and they are fired even though the regular toolbar is hidden. The CAB is not intercepting the clicks unless it has an action in the clicked point. If I click over CM, it is handled correctly: RM is not shown because that button is exactly below the CM menu.

这是一个错误吗?任何解决办法?

Is this a bug? Any workaround?

测试在Android 4.1设备。

Tested in an Android 4.1 device.

推荐答案

我认为这是一个错误。我遇到了它自己,而<一href=\"http://stackoverflow.com/questions/29714057/contextual-action-mode-not-filtering-touches\">isolated它的。这是一种解决方法,假设你正在扩展 AppCompatActivity

I consider it a bug. I have run into it myself, and isolated it. Here is a workaround, assuming you are extending AppCompatActivity:

@Override
public void onSupportActionModeStarted(ActionMode mode) {
    super.onSupportActionModeStarted(mode);
    rm1.setEnabled(false);
    rm2.setEnabled(false);
    rm3.setEnabled(false);
}

@Override
public void onSupportActionModeFinished(ActionMode mode) {
    super.onSupportActionModeFinished(mode);
    rm1.setEnabled(true);
    rm2.setEnabled(true);
    rm3.setEnabled(true);
}

这篇关于上下文操作栏与工具栏操作搞乱的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆