如何检测,如果actionmode已经present [英] how to detect if actionmode already present

查看:237
本文介绍了如何检测,如果actionmode已经present的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有几个小部件在一个视图中,每个需要自己的ActionMode。我看到ActionMode不会自动当用户点击操作栏外解雇。因此,能够容易地为用户启动ActionMode一个控制,然后点击(longclick在我的情况),另一个控制和堆栈第二个动作条上的第一个顶部。这将导致程序逻辑混乱。

I have several widgets in a view, each needing its own ActionMode. I see that the ActionMode does not dismiss automatically when the user taps outside the action bar. Thus, it is easily possible for the user to start an ActionMode for one control, then tap (longclick in my case) another control and stack a second ActionBar on top of the first. This causes programming logic havoc.

我可以跟踪当前ActionMode与活动级别的成员变量和罢免是否需要一个新的当前之一。 Howewver,这使我的code凌乱阅读和维护。并进一步,我想preFER立即当用户点击操作栏以外的任何东西将其关闭。

I can keep track of the current ActionMode with an activity-level member variable and dismiss the current one if a new one is needed. Howewver, this is making my code messy to read and maintain. And further, I'd prefer to dismiss it immediately when the user taps anything outside the action bar.

这是一个很好的方法来处理这​​有什么建议?

Any suggestions on a good way to handle this?

推荐答案

我前一段时间一直在寻找这个问题的解决方案,因为我知道你不可能不保存当前的动作模式状态在一个全局变量跟踪它。不过,我不认为一个变量与正确的名称将使你的code凌乱。

I was looking for a solution of this problem some time ago and as I know you couldn't track it without saving current action-mode state in a global variable. However I don't think that one variable with proper name would make your code messy.

这篇关于如何检测,如果actionmode已经present的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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