WebView显示空白页面而不是加载链接

时间:2016-11-17 08:12:02

标签: java android webview

我正在尝试在我的WebView中打开以下链接

http://issuu.com/muhammadumar88/docs/prime_guide_2016?e=27032292/40838888

使用代码

mWebView = (WebView) view.findViewById(webView);
        mWebView.getSettings().setJavaScriptEnabled(true);

        mWebView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
        WebSettings websettings = mWebView.getSettings();
        websettings.setJavaScriptEnabled(true);
        websettings.setDomStorageEnabled(true);
        websettings.setUserAgentString("Mozilla/5.0 (Linux; Android 4.1.2; C1905 Build/15.1.C.2.8) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/34.0.1847.114 Mobile Safari/537.36");

        mWebView.setWebViewClient(new AppWebViewClient((ProgressBar) view.findViewById(R.id.progressBar)));
        mWebView.setWebChromeClient(new WebChromeClient());
        mWebView.loadUrl(link);



public class AppWebViewClient extends WebViewClient
    {
        private ProgressBar progressBar;

        public AppWebViewClient(ProgressBar progressBar)
        {
            this.progressBar = progressBar;
            progressBar.setVisibility(View.VISIBLE);
        }
        @Override
        public boolean shouldOverrideUrlLoading(WebView view, String url)
        {
            view.loadUrl(url);
            return true;
        }

        @Override
        public void onPageFinished(WebView view, String url)
        {
            super.onPageFinished(view, url);
            progressBar.setVisibility(View.GONE);
        }
    }

我继续得到一个白色的空白页面。我怎么能解决它,我缺少什么?

1 个答案:

答案 0 :(得分:1)

更改以下行。

var str = 'apple_mango_banana';
var arr = ['apple','banana'];

var isEvery = arr.every(item => str.includes(item));

console.log(isEvery);

而不是

 mWebView = (WebView) view.findViewById(R.id.webView);

有关详细信息,请参阅Webview shows white blank page