Android系统。我怎么能显示进度条加载数据的WebView? [英] Android. How can i show progress bar while loading data to webview?
本文介绍了Android系统。我怎么能显示进度条加载数据的WebView?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能显示在加载数据的进度条到我的WebView?问题是不是当我从URL加载数据,什么时候我加载数据(HTML)? 我的code: `
How can i show progress bar while loading data to my webview ? problem is not when i load data from url,exactly when i load data (html)? my code : `
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);
}
});
String summary = "<img src=\"http://img.domo.by/images/custom/images/MDFShpon600.jpg\" />"
webview.loadData(summary, "text/html", "utf-8");
`
推荐答案
请尝试以下code,
ProgressDialog progDailog = ProgressDialog.show( context,"Process ", "Loading Data...",true,true);
new Thread ( new Runnable()
{
public void run()
{
// your data loading code goes here
}
}).start();
Handler progressHandler = new Handler()
{
public void handleMessage(Message msg1)
{
progDailog.dismiss();
}
}
这篇关于Android系统。我怎么能显示进度条加载数据的WebView?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文