IT狗

WebView断网提示

转载请标明出处,维权必究https://www.cnblogs.com/tangZH/p/9913968.html 

 

重写WebViewClient中的方法,然后WebView.setWebViewClient(mWebViewClient);

    WebViewClient mWebViewClient = new WebViewClient() {        @Override        public boolean shouldOverrideUrlLoading(WebView view, String url) {return false;        }        @Override        public void onPageStarted(WebView view, String url, Bitmap favicon) {            super.onPageStarted(view, url, favicon);        }        @Override        public void onPageFinished(WebView view, String url) {            super.onPageFinished(view, url);        }        @Override        public void onLoadResource(WebView webView, String s) {            super.onLoadResource(webView, s);        }        @Override        public void onScaleChanged(WebView webView, float v, float v1) {            super.onScaleChanged(webView, v, v1);        }        @Override        public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
mWebView.loadUrl("");//避免出现默认错误页 showErrorView();
} };

此文由 IT狗 编辑,本网站所发布展示的作品/文章版权归原作者所有,任何商业用途均须联系作者!

相关推荐

评论 暂无评论