Like Mark said:

mWebView.setWebViewClient(new WebViewClient() {
         public void onReceivedError(WebView view, int errorCode, String
description, String failingUrl) {
         //do something on error
         }
});

The WebView will show a default error message and due to a bug in Android,
this message is tricky to hide. I solved it by setting the parent view
visibility to GONE and calling mWebView.setData with an empty string.

Google code page for the android issue:
http://code.google.com/p/android/issues/detail?id=2340&q=webview%20error&colspec=ID%20Type%20Status%20Owner%20Summary%20Stars

Best,
J

On Mon, Feb 14, 2011 at 1:21 PM, Craigbtx <craig...@austin.rr.com> wrote:

> I am using webview. If the page is not correct or the website is down,
> how can I error trap a page not found and show the users an error page
> or some
>
> othe page?
>
> I am very much a beginner so I need examples of code.
>
>
>  @Override
>    public void onCreate(Bundle savedInstanceState) {
>        super.onCreate(savedInstanceState);
>        setContentView(R.layout.main);
>
>        WebView webview = new WebView(this);
>        setContentView(webview);
>
>        WebSettings webSettings = webview.getSettings();
>        webSettings.setJavaScriptEnabled(true);
>        webSettings.setBuiltInZoomControls(true);
>
>        // No error trapping
>        webview.setWebViewClient(new WebViewClient());
>        webview.loadUrl("http://www.MyWebsite.com";);
>
> --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to android-developers@googlegroups.com
> To unsubscribe from this group, send email to
> android-developers+unsubscr...@googlegroups.com
> For more options, visit this group at
> http://groups.google.com/group/android-developers?hl=en

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to