如何将分享按钮添加到了一个EditText文本选择吧? [英] How to add a share button to the text selection bar for an 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屋!