如何在将数据加载到我的webview时显示进度条? 我的代码:Android:如何在将数据加载到WebView时显示进度条?
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
this.requestWindowFeature(Window.FEATURE_PROGRESS);
getWindow().setFeatureInt(Window.FEATURE_PROGRESS, Window.PROGRESS_VISIBILITY_ON);
this.setProgressBarVisibility(true);
setContentView(R.layout.layout_article);
WebView webview = (WebView) findViewById(R.id.webView);
final Activity activity = this;
webview.setWebChromeClient(new WebChromeClient() {
public void onProgressChanged(WebView view, int progress) {
activity.setProgress(progress * 100);
}
});
webView.loadUrl("http://google.com");
}
你需要上传移动到一个单独的线程,以释放处理主UI线程。您还必须决定是否显示微调框或进度栏。 – 2012-02-21 09:56:12
最好的方法是由Paresh建议,但是你必须使用'WebViewClient',使用这个技术你不必看看你从服务器上获取了多少数据。 – Yuvi 2012-02-21 10:26:24
我希望以下链接将帮助您: http://stackoverflow.com/questions/9171510/how-to-show-a-progress-dialog-while-html-page-is-loaded-in-webview/9171581 #9171581 – 2012-02-21 10:40:28