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:
- Create a custom subclass of
WebViewClient
, overridingonPageFinished()
- Attach an instance of your
WebViewClient
subclass to yourWebView
viasetWebViewClient()
- Set up the indefinite progress indicator (bar, dialog,
RotateAnimation
, etc.) before callingloadUrl()
on theWebView
- Have
onPageFinished()
get rid of the progress indicator
CommonsWare
2010-03-29 12:23:45
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
2010-10-21 22:27:54
+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
2010-03-29 12:40:58
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
2010-08-04 10:07:28