English 中文(简体)
将 WebView 中的“ 网络页面不可用” 错误替换为不那么丑的吗? (Android)
原标题:Replace a "Web page not available" Error in WebView with something less ugly? (Android)

我有一个 WebView 活动, 有时由于连接断开或贫困 WIFI/ DATA 连接而没有适当加载。 我想一旦我的应用程序被安装到现实世界里, 这很有可能发生。 我的问题是, 我如何用更漂亮的东西来取代这个丑陋的错误?

Also, do you have any other tips for getting my WebView Activity to NOT resemble a browser? For example, instead of a white screen showing up while the WebView is loading, how can I show a loading icon during this moment?

非常感谢。

最佳回答

当找不到页面时,页面返回404个错误,您需要处理它。

可以通过设定 WebViewClient 和压倒 on receivedError 方法来做到这一点。

你可以尝试这样的东西:

    WebView wv = (WebView) findViewById(R.id.webView);
 wv.setWebViewClient(new WebViewClient() {
    @Override
    public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
             //handle the 404
            super.onReceivedError(view, errorCode, description, failingUrl);
    }
 });
问题回答

暂无回答




相关问题
CSS working only in Firefox

I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....

image changed but appears the same in browser

I m writing a php script to crop an image. The script overwrites the old image with the new one, but when I reload the page (which is supposed to pickup the new image) I still see the old one. ...

Firefox background image horizontal centering oddity

I am building some basic HTML code for a CMS. One of the page-related options in the CMS is "background image" and "stretch page width / height to background image width / height." so that with large ...

Separator line in ASP.NET

I d like to add a simple separator line in an aspx web form. Does anyone know how? It sounds easy enough, but still I can t manage to find how to do it.. 10x!

热门标签