简体   繁体   English

Android:如何捕获文本上的全局双击事件?

[英]Android: How to catch the global double-click events on text?

Is it possible to catch the global double-click events on text in Android ? 是否可以在Android捕获文本上的全局double-click事件? If so, how to do it? 如果是这样,该怎么办? Should I get root right first? 我应该先root吗?

To be more specifically, when I double-click the text area in the built-in apps, the text will be selected and it will pop a menu to operate on it. 更具体地说,当我double-click内置应用程序中的文本区域时,将选择文本并弹出菜单以对其进行操作。

在此处输入图片说明

However, in other apps, such behaviour will not occur. 但是,在其他应用程序中,不会发生这种行为。 Hence, I would like to catch the global the double-click events and customize the pop-menu. 因此,我想捕捉全局的double-click事件并自定义弹出菜单。

Any solutions or advices will be appreciated. 任何解决方案或建议,将不胜感激。


Edit: 编辑:

I would like to catch double-click events in other apps, not in my apps. 我想在其他应用程序而不是我的应用程序中捕获double-click事件。 My apps is to make such event-catching possible. 我的应用程序是为了使此类事件捕获成为可能。

Yes, You have to set EditText android:textIsSelectable="true" 是的,您必须将EditText设置为android:textIsSelectable="true"

And create Action mode callback 并创建动作模式回调

for more info see this 有关更多信息,请参阅

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM