views:

914

answers:

2

Hi

In an android app I am using a tabview for an app and one of the tabs shows a webview. But the page is blank until the web page loads. how would one show a progress bar until the page loads. It cannot be in the title bar because that is hidden by the tabhost

+1  A: 

There's a really good tutorial on the Android Developers website for that. It shows how to create the 'spinning wheel' progress dialog used throughout Android programs, and even some basics on how to handle loading in a separate thread to prevent your application from freezing while loading.

Steve H
In terms of page loading, you can attach a `WebViewClient` to the `WebView` and find out when the page is loaded, so you know when you can dismiss the dialog.
CommonsWare
ok but how to relaunch the progressDialog when clicking on a link inside webview ?
Samuel
A: 

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

Create a custom subclass of WebViewClient, overriding onPageFinished() Attach an instance of your WebViewClient subclass to your WebView via setWebViewClient() Set up the indefinite progress indicator (bar, dialog, RotateAnimation, etc.) (progressDialog = ProgressDialog.show(this, "", getText(R.string.progressDialogText), true);) before calling loadUrl() on the WebView Have onPageFinished() get rid of the progress indicator (progressDialog.dismiss())

fmo