小编DrB*_*rad的帖子

Webview 不支持 HTML select 元素

所以我的网络视图无法使用选择元素。换句话说,当我单击任何页面上的选择元素时,它不会显示菜单。

html 选择元素示例:

<select>
    <option>test</option>
    <option>testing it</option>
    <option>bla bla bla</option>
</select>
Run Code Online (Sandbox Code Playgroud)

java 创建我的网络视图:

        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));
                DownloadManager dm = (DownloadManager) activity.getSystemService(DOWNLOAD_SERVICE);
                dm.enqueue(request);

                Toast toast …
Run Code Online (Sandbox Code Playgroud)

html java android webview

3
推荐指数
1
解决办法
3525
查看次数

标签 统计

android ×1

html ×1

java ×1

webview ×1