How to listen for a WebView finishing loading a URL?

Janusz picture Janusz · Jun 30, 2010 · Viewed 345k times · Source

I have a WebView that is loading a page from the Internet. I want to show a ProgressBar until the loading is complete.

How do I listen for the completion of page loading of a WebView?

Answer

ian picture ian · Jun 30, 2010

Extend WebViewClient and call onPageFinished() as follows:

mWebView.setWebViewClient(new WebViewClient() {

   public void onPageFinished(WebView view, String url) {
        // do your stuff here
    }
});