是否有可能创建的Andr​​oid版本pre棉花糖定制浮动文本选择菜单? [英] Is it possible to create a custom floating text selection menu in Android versions pre Marshmallow?

查看:360
本文介绍了是否有可能创建的Andr​​oid版本pre棉花糖定制浮动文本选择菜单?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在找创建文本选择自定义菜单。我知道这是可能的编辑与setCustomSelectionActionModeCallback操作栏的行为,但对我来说,我不希望这样的动作条在所有表演,我想我已经实现了我自己的浮动自定义菜单。

I'm looking to create a custom menu for text selection. I know it's possible to edit the behaviour of the action bar with setCustomSelectionActionModeCallback, but in my case I don't want that action bar to show at all, I want my own floating custom menu which I have already achieved.

唯一的事情是,有没有办法在TextView中选择文本后不显示操作栏菜单。

Only thing is that there is no way to not show the action bar menu after selecting the text in the TextView.

我需要的行为不是标准剪切/复制/粘贴,我已经实现的行动是突出显示和保存文本的突出显示部分到数据库。

The behaviour I need is not the standard cut/copy/paste, the actions I have implemented are for highlighting and saving the highlighted section of text to a database.

我已经做了一些修修补补,我能做的最好的是一个混乱的反射,从而想法我回来在onCreateActionMode虚假和文本选择手柄通过反射得到引用。它一半的工作,它的一样好,因为任何形式的在这种情况下反思是非常不好的做法。

I have done some tinkering and the best I could do was a messy reflection idea whereby I returned false in onCreateActionMode and got references to the text selection handles through reflection. It half worked and it's just as well because any form of reflection in this case is very bad practice.

我的希望是,最后的支持库将包含在6.0的浮动文本菜单,我虽然我可以实现在该菜单我自己的自定义视图,但这是一厢情愿的想法。

My hope was that the last support library would have included the floating text menu in 6.0, and I though I could implement my own custom view in that menu, but that's wishful thinking.

如果任何人有可能是使用的话,我洗耳恭听。

If anyone has any ideas or libraries that might be of use then I'm all ears.

推荐答案

正如你已经注意到了,使用反射是途径之一。我是pretty确保它是唯一一个。如果你有兴趣在我与该菜单做了,检查出碳。它的EditText确实pretty多少你需要什么,但与反思为好。

As you already noticed, using reflection is one of the ways. I'm pretty sure that it's the only one. If you're interested in what I did with that menu, check out Carbon. Its EditText does pretty much what you need, but with reflection as well.

在code段是太长的方式给它贴在这里,但这里有链接:

The code snippet is way too long to paste it here, but here are the links:

<一个href=\"https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/widget/EditText.java\" rel=\"nofollow\">https://github.com/ZieIony/Carbon/blob/master/carbon/src/main/java/carbon/widget/EditText.java
https://plus.google.com/109054799904873578131/posts/BH6r9J5gnw6

在这里输入的形象描述

基本上我躲在看中三星的菜单,停用标准的操作模式,并显示自己的弹出窗口与连接到标准的复制/粘贴单击处理选项。

Basically I'm hiding the fancy Samsung's menu, disable the standard Action Mode and show my own popup window with options connected to standard copy/paste click handlers.

这篇关于是否有可能创建的Andr​​oid版本pre棉花糖定制浮动文本选择菜单?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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