jasonflaherty
jasonflaherty

Reputation: 1944

Show Loading Dialog until webpage fully loads in WebView

I have a page that loads some data in a webview.

webView.loadUrl();

How can I have a dialog with "loading..." in it show until the page finishes loading in the webview?

Do I need to get the network speed? Is there a FINISHEDLOADING() method I can use?

Upvotes: 1

Views: 1357

Answers (1)

Evos
Evos

Reputation: 3915

You can use WebViewClient callbacks. There are OnPageFinished() callback and lots of other useful things.

webview.setWebViewClient(new WebViewClient() {
   public void public void onPageFinished (WebView view, String url) {
       ......some code here..
   }
 });

So all you need to do is show progress right after webview.loadUrl() method and dismiss it in onPageFinished() callback method.

Upvotes: 6

Related Questions