[英]Add the selected item of a popup menu to a text field which is in same form
[英]How to add an item to the text selection popup menu?
本博客教程将向您展示如何操作: https : //medium.com/google-developers/custom-text-selection-actions-with-action-process-text-191f792d2999
基本上,在您的Manifest
文件中,将PROCESS_TEXT intent filter
添加到将处理从弹出菜单共享的文本的活动。
<activity
android:name=".ProcessTextActivity"
android:label="@string/process_text_action_name">
<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>
然后,您将像这样在您的Activity
处理该文本
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.process_text_main);
CharSequence text = getIntent()
.getCharSequenceExtra(Intent.EXTRA_PROCESS_TEXT);
// process the text
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.