2
我想加载一个网页。如何处理webview内部的错误?
我想处理网页加载错误。我知道这个错误可以在onReceivedError(...)
方法中获得。
我的问题是如何处理错误,而不显示Page Not found
在webview? (例如:显示一个对话框,并使webview为空)。
在此先感谢。
我想加载一个网页。如何处理webview内部的错误?
我想处理网页加载错误。我知道这个错误可以在onReceivedError(...)
方法中获得。
我的问题是如何处理错误,而不显示Page Not found
在webview? (例如:显示一个对话框,并使webview为空)。
在此先感谢。
检查为:
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
Log.e("ProcessPayment", "onReceivedError = " + errorCode);
//404 : error code for Page Not found
if(errorCode==404){
// show Alert here for Page Not found
view.loadUrl("file:///android_asset/Page_Not_found.html");
}
else{
}
}
public void onReceivedError(WebView view, int errorCode, String description,
String failingUrl) {
if (errorCode == ERROR_HOST_LOOKUP || errorCode == ERROR_FILE_NOT_FOUND) {
// TODO your dialog here
}
}
是否有可能作出某种错误发生的WebView空白? –
看到我的编辑答案 –
我在onReceivedError中显示了一条警告。但是webview会加载错误页面。 –