[英]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.