2017-08-13 20 views
1

我試圖在我的cordova-plugin中禁用contextmenu很長一段時間,但是甚至沒有找到解決問題的好方法。如何禁用Android的上下文菜單

我想我不得不以某種方式初始化我的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以修改在web視圖參考覆蓋活動Activity中的「onCreateActionMode」方法。但CordovaWebView是一個接口,沒有類,我不想實現整個接口,我不認爲這是必要的。

如果有人對此有任何意見,請讓我知道。

回答