Android 8不支持WebView中的HTML数据列表

时间:2019-11-12 11:12:58

标签: java android webview android-webview

我有一个asp.net网络应用程序,该应用程序已在具有 webview应用程序的android智能手机中使用。直到Android 8都可以正常工作。在android 8中,我的所有下拉列表(由html输入和数据列表制成)都无法正常工作。它只是作为html文本输入。

是否需要更改任何设置才能使其正常工作。我也尝试了离子型的webview应用程序,但结果仍然相同。

我的MainActivity.java代码:

package com.example.webviewapp;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Context;
import android.content.MutableContextWrapper;
import android.os.Build;
import android.os.Bundle;
import android.webkit.WebSettings;
import android.webkit.WebView;
import android.webkit.WebViewClient;
import android.view.View;


public class MainActivity extends AppCompatActivity {
    private WebView mywebView;
    String webURL="http://vpj.amio.in";
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        mywebView = (WebView) findViewById(R.id.webview);
        WebSettings webSettings= mywebView.getSettings();
        webSettings.setJavaScriptEnabled(true);
        mywebView.setWebViewClient(new WebViewClient());
        mywebView.clearCache(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
            mywebView.getSettings().setDomStorageEnabled(true);
        }
        //improve webView performance
        mywebView.getSettings().setRenderPriority(WebSettings.RenderPriority.HIGH);
        mywebView.getSettings().setCacheMode(WebSettings.LOAD_CACHE_ELSE_NETWORK);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
            mywebView.getSettings().setAppCacheEnabled(true);
        }
        mywebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.ECLAIR_MR1) {
            webSettings.setDomStorageEnabled(true);
        }
        webSettings.setLayoutAlgorithm(WebSettings.LayoutAlgorithm.NARROW_COLUMNS);
        webSettings.setUseWideViewPort(true);
        webSettings.setSavePassword(true);
        webSettings.setSaveFormData(true);
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB) {
            webSettings.setEnableSmoothTransition(true);
        }
        if (savedInstanceState == null)
        {
            mywebView.loadUrl(webURL);
        }

    }
    @Override
    protected void onSaveInstanceState(Bundle outState )
    {
        super.onSaveInstanceState(outState);
        mywebView.saveState(outState);
    }

    @Override
    protected void onRestoreInstanceState(Bundle savedInstanceState)
    {
        super.onRestoreInstanceState(savedInstanceState);
        mywebView.restoreState(savedInstanceState);
    }
    @Override
    public void onBackPressed() {
        if(mywebView.canGoBack())
        {
            mywebView.goBack();
        }

        else
        {
            super.onBackPressed();
        }
    }
}

Android Manifest.xml代码:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    package="com.example.webviewapp"
    tools:ignore="ExtraText,MissingVersion"
    android:versionName="1.0"
    android:versionCode="1">

    <uses-permission android:name="android.permission.INTERNET"
    android:hardwareAccelerated="true" />
    <application
        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="VPJ CrushMate"
        android:supportsRtl="true"
        android:usesCleartextTraffic="true"
        android:theme="@style/AppTheme"
        tools:ignore="GoogleAppIndexingWarning,RtlEnabled"
        tools:targetApi="donut">
        <activity android:name=".MainActivity"
            android:configChanges="orientation|screenSize">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

如果这些下拉菜单不起作用,我的应用程序将无用。因此,请帮忙。 谢谢

0 个答案:

没有答案