【问题标题】:How to disable contextual menu for Android如何禁用 Android 的上下文菜单
【发布时间】:2018-01-21 17:09:11
【问题描述】:

我正在尝试禁用我的 cordova-plugin 中的上下文菜单很长一段时间,但甚至没有找到解决问题的好方法。

我认为在以某种方式初始化我的cordova-plugin 时,我必须从活动中覆盖“onCreateContextMenu”方法。但我不知道如何正确覆盖它。

公共类 ContextMenuPlugin 扩展 CordovaPlugin {

 @Override
 public void initialize(CordovaInterface cordova, CordovaWebView webView) {

      //when overriding the onCreateContextMenuListener in View I gets executed, but nothing happens (maybe it's the wrong View?)
      webView.getView().setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {

           @Override
           public void onCreateContextMenu (ContextMenu menu, View v, ContextMenu.ContextMenuInfo menuInfo) {
                //when logging something in here it is written when the context menu is created
                //but i cannot seem to be able to modify the menu variable
           }
      });

      super.initialize(cordova, webView);
 }

}

如果这个视图是错误的视图,也许我必须重写 CordovaWebView 以修改 webView 中引用的 Activity 以重写 Activity 中的“onCreateActionMode”方法。但是 CordovaWebView 是一个接口,没有类,我不想实现整个接口,我真的不相信这是必要的。

如果有人对此有任何想法,请告诉我。

【问题讨论】:

    标签: android cordova meteor cordova-plugins contextmenu


    【解决方案1】:

    使用此处引用的解决方案:

    Disable callout (context menu) on Android

    它与你的 Java 代码无关。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-09-27
      • 1970-01-01
      • 2015-04-21
      • 1970-01-01
      • 2011-03-25
      • 1970-01-01
      • 2011-03-18
      相关资源
      最近更新 更多