问题
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