所以我的 webview 不能使用 select 元素。換句話說,當我單擊任何頁面上的選擇元素時,它不會顯示菜單。html 選擇元素示例:<select> <option>test</option> <option>testing it</option> <option>bla bla bla</option></select>java創(chuàng)建我的webview: NestedWebView nwv = new NestedWebView(activity.getApplicationContext()); nwv.setLayoutParams(new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); registerForContextMenu(nwv); nwv.setWebViewClient(new webViewClient()); nwv.setWebChromeClient(new webChromeClient(nwv)); nwv.addJavascriptInterface(new JSInterface(), "drconsole"); nwv.getSettings().setJavaScriptEnabled(true); nwv.getSettings().setLoadWithOverviewMode(true); nwv.getSettings().setUseWideViewPort(true); nwv.getSettings().setSupportZoom(true); nwv.getSettings().setBuiltInZoomControls(true); nwv.getSettings().setDisplayZoomControls(false); nwv.getSettings().setAllowFileAccess(true); nwv.getSettings().setJavaScriptCanOpenWindowsAutomatically(true); nwv.getSettings().setSupportMultipleWindows(true); nwv.getSettings().setGeolocationEnabled(true); nwv.setDrawingCacheEnabled(true); nwv.getSettings().setPluginState(WebSettings.PluginState.ON); nwv.loadUrl(url); nwv.setDownloadListener(new DownloadListener(){ @Override public void onDownloadStart(String url, String userAgent, String contentDisposition, String mimetype, long contentLength){ try{ DownloadManager.Request request = new DownloadManager.Request(Uri.parse(url)); String filename = new URL(url).getFile(); request.allowScanningByMediaScanner(); request.setNotificationVisibility(DownloadManager.Request.VISIBILITY_VISIBLE_NOTIFY_COMPLETED); request.setDestinationInExternalPublicDir(Environment.DIRECTORY_DOWNLOADS, filename.substring(filename.lastIndexOf('/')+1)); } } });我也幾乎可以使用 webviewclient 和 webchromeclient 。請在對我的問題投票之前發(fā)表評論。
1 回答

MYYA
TA貢獻1868條經驗 獲得超4個贊
要修復此錯誤,必須使用活動而不是應用程序上下文來初始化 webview。
這一行:
NestedWebView nwv = new NestedWebView(activity.getApplicationContext());
一定是:
NestedWebView nwv = new NestedWebView(activity);
添加回答
舉報
0/150
提交
取消