views:

1880

answers:

3

I have looked at a question similar to this here but as I am a newbie could someone explain how to get this to work in a WebView or at least how to set a 10 second time delay so people know that it's loading?

+4  A: 

If your question is "how do I find out when the page is loaded?", then:

  1. Create a custom subclass of WebViewClient, overriding onPageFinished()
  2. Attach an instance of your WebViewClient subclass to your WebView via setWebViewClient()
  3. Set up the indefinite progress indicator (bar, dialog, RotateAnimation, etc.) before calling loadUrl() on the WebView
  4. Have onPageFinished() get rid of the progress indicator
CommonsWare
This works when activity starts, but if I use shouldOverrideUrlLoading it doesn't work when clicking on a link. What's the best solution ?
Samuel
+1  A: 

I have just found a really good example of how to do this here: http://developer.android.com/reference/android/webkit/WebView.html . You just need to change the setprogress from:

activity.setProgress(progress * 1000);

to

activity.setProgress(progress * 100);
Max Marroni
A: 

It's true, there are also more complete option, like changing the name of the app for a sentence you want. Check this tutorial it can help:

http://www.firstdroid.com/2010/08/04/adding-progress-bar-on-webview-android-tutorials/

In that tutorial you have a complete example how to use the progressbar in a webview app.

Adrian.

Adrian Zelezniak