How to add a share button to the text selection bar for an EditText?

二次信任 提交于 2020-01-14 04:43:06

问题


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

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

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


回答1:


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

TextView.setCustomSelectionActionModeCallback(ActionMode.Callback)

and so the EditText

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

Also visit TextView.html#setCustomSelectionActionModeCallback



来源:https://stackoverflow.com/questions/22572711/how-to-add-a-share-button-to-the-text-selection-bar-for-an-edittext

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!