我的应用程序中有一个带有wrap_content宽度和高度的WebView
在我使用webview.loadData之前,它的宽度和高度为0,
加载网址后(或者我使用webview.loadData),它会显示一个网页.
我的问题是,我如何清除webview以将其恢复到原始状态,就像
在它之前loadData ??
有没有人知道在WebView中是否有办法拦截"找不到页面"或"页面未加载错误"?
根据android文档,onReceivedError()应该可以拦截.但我在一个应用程序测试它,我删除了错误的URL,它没有做任何事情.
我希望我的应用程序能够提供我自己的自定义错误消息,如果URL由于任何原因不可用.
这是没有做任何事情的代码:
public void onReceivedError(WebView view, int errorCode,
String description, String failingUrl) {
// custom error handling ... show and alert or toast or something
}
Run Code Online (Sandbox Code Playgroud) I'm out to do something when no connection is available page/alert in WebView (e.g. load a local html page or alert). I've to play with Prevent WebView from displaying "web page not available" but without any success. Any suggestions would be appreciated.