I have an activity with a webview where I show an external web page, it occasionally takes time to load so I would like to put a progress bar or a message on it, this to prevent the user from thinking that more than the delay is that the application is not working.
This is how I have implemented the WebView:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.portal_web);
String url="http://www.uniagustiniana.edu.co/";
WebView view=(WebView) this.findViewById(R.id.webView01);
view.getSettings().setJavaScriptEnabled(true);
view.loadUrl(url);
}
what you are trying to do is not complicated, you just have to override the OnPageFinished method
How to load web page in a WebView and show a progress bar.
This can be done by implementing a
WebViewClient
yourWebView
and using the onPageFinished() method to determine that the page has been fully loaded, at which point you remove the dialog using thedismiss()
del methodProgressBar
.When
WebView
it is in the process of loading the content, theProgressBar
, at the end it disappears.You can even change the style to look like a progress bar:
As another option, you can even implement a
Asynctask
to show the loading progress.How to display a ProgressBar while getting a response from the server?