How to add item into popup copy/paste menu on a android selected textview?

a 夏天 提交于 2020-01-01 08:52:52

问题


please look this screenshot. In normal case, when text be selected, a popup menu opened, but only have cut/paste item. I want to know, how to add item just like this "web search / share" into this popup menu?

What's this popup menu? I had tried to override Activity Context or Option Menu, but it' not. I had also tried to extends TextView and override it's Context menu, but no use, only show a normal dialog context menu, and this cut/paste menu disappered.


回答1:


Before the api23,I have no ideal too. But now we can get it use ACTION_PROCESS_TEXT with api23. Include this code in the AndroidManifest.xml file.

 <activity
        android:name=".YourActivity">
        <intent-filter>
            <action android:name="android.intent.action.PROCESS_TEXT" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
</activity>

Install your app, then you can find your app name in the text selection menu.

Read the documentation for more information.



来源:https://stackoverflow.com/questions/34439851/how-to-add-item-into-popup-copy-paste-menu-on-a-android-selected-textview

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