I use webviewto show a webpage in my application. Downloading a web page takes about 2-3 seconds. Before loading the webpage, I want to show a progress bar, as shown in the figure here . This is what a range of activities looks like:

How can i do this?
I searched the Internet, but could not find a satisfactory and correct explanation of how it is implemented. Thank!
WebViewPage.java
public class Webpage extends Activity {
WebView web;
ProgressBar progressBar;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web_page);
Intent startwebpage = getIntent();
web = (WebView) findViewById(R.id.webView);
web.setWebViewClient(new myWebClient());
web.getSettings().setJavaScriptEnabled(true);
web.loadUrl("http://www.google.com");
}
public class myWebClient extends WebViewClient
{
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon) {
super.onPageStarted(view, url, favicon);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
@Override
public void onPageFinished(WebView view, String url) {
super.onPageFinished(view, url);
}
}
}
source
share