[Java] 纯文本查看 复制代码
在webview加载网页之前
if(Build.VERSION.SDK_INT >= 19) {
webView.getSettings().setLoadsImagesAutomatically(true);
} else {
webView.getSettings().setLoadsImagesAutomatically(false);
}
然后在onpagefinished方法里面做监听,当页面完成的时候再去做相应的加载图片
public void onPageFinished(WebView view, String url) {
if(!webView.getSettings().getLoadsImagesAutomatically()) {
webView.getSettings().setLoadsImagesAutomatically(true);
}
}
[Java] 纯文本查看 复制代码
public void onReceivedError (WebView view, int errorCode, String description, String failingUrl) {
super.onReceivedError(view, errorCode, description, failingUrl);
loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
switch(errorCode){
case 404:
errorView.setBackgroundRes...(XXXXX);
break;
}
errorView.setVisibility(View.VISIBLE);
}