如何将分享按钮添加到了一个EditText文本选择吧? [英] How to add a share button to the text selection bar for an EditText?

查看:307
本文介绍了如何将分享按钮添加到了一个EditText文本选择吧?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我注意到,在WebView中突出显示文本时使用的标准拷贝出现沿分享按钮,选择所有按钮:

I notice that when highlighting text in a WebView a share button appears along with the standard copy and select all buttons:

,但在一个TextView或EditText上突出显示文本时,不存在这样的按钮。

but when highlighting text in a TextView or EditText, there is no such button.

有没有办法通过XML增加类似的按钮还是可以编程方式?

Is there any way to add such a button via XML or can it be done programmatically?

推荐答案

您可以通过设置自定义选择操作方式实现这一

You can achieve that by setting a custom selection action mode using

TextView.setCustomSelectionActionModeCallback(ActionMode.Callback)

和使的EditText

<一个href=\"http://stackoverflow.com/questions/12995439/custom-cut-copy-action-bar-for-edittext-that-shows-text-selection-handles\">Here's与类似的问题,得到的回答是一个例子

Here's a similar question with that was answered with an example

还行<一个href=\"http://developer.android.com/reference/android/widget/TextView.html#setCustomSelectionActionModeCallback%28android.view.ActionMode.Callback%29\"相对=nofollow> TextView.html#setCustomSelectionActionModeCallback

这篇关于如何将分享按钮添加到了一个EditText文本选择吧?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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