【问题标题】:Add custom action on clipboard option在剪贴板选项上添加自定义操作
【发布时间】:2021-06-02 23:13:01
【问题描述】:

当我们选择 URL 时,我想像 Chrome 一样在剪贴板上添加选项

是否可以在剪贴板中添加我的应用程序选项?

谢谢。

【问题讨论】:

    标签: android xamarin xamarin.forms xamarin.android


    【解决方案1】:

    我对 Xamarin 一无所知。但在原生 Android 中,它是通过这种方式完成的。
    向清单中的 Activity 添加意图过滤器:

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

    来自android:label 的文本将显示在上下文菜单中

    this Android developers blog post中有详细描述

    关于同一主题的另一个问题:How to use the new Android M feature of "Text Selection" to be offered from outside of your app?

    【讨论】:

      【解决方案2】:

      对于您想要自定义菜单的每个TextView,您需要将自己的android.view.ActionMode.Callback 传递给TextView.setCustomSelectionActionModeCallback 函数。

      android.view.ActionMode.Callback 的实现中,您可以随意添加/编辑/删除项目。

      更新:没有意识到这个问题在 Xamarin 平台上。 我想答案应该是相似的。

      【讨论】:

        猜你喜欢
        • 2013-12-19
        • 1970-01-01
        • 2016-01-04
        • 2012-08-07
        • 1970-01-01
        • 1970-01-01
        • 2015-10-06
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多