如何禁用Android的上下文菜单

如何禁用Android的上下文菜单,android,cordova,meteor,cordova-plugins,contextmenu,Android,Cordova,Meteor,Cordova Plugins,Contextmenu,我尝试禁用cordova插件中的contextmenu已经有一段时间了,但没有找到解决问题的好方法 我想在初始化cordova插件时,我必须重写活动中的“onCreateContextMenu”方法。但我不知道如何正确地覆盖它 公共类ContextMenuPlugin扩展了CordovaPlugin{ @Override public void initialize(CordovaInterface cordova, CordovaWebView webView) { //wh

我尝试禁用cordova插件中的contextmenu已经有一段时间了,但没有找到解决问题的好方法

我想在初始化cordova插件时,我必须重写活动中的“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中引用的活动,以重写活动中的“onCreateActionMode”方法。但是CordovaWebView是一个接口,没有类,我不想实现整个接口,我真的不相信这是必要的


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

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


它与Java代码无关。

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

它与Java代码无关