我想从服务器显示一些文本,但在此之前我想显示进度条。
谁能帮我吗。回复的格式为JSON
答案 0 :(得分:4)
怎么样?
http://www.firstdroid.com/2010/08/04/adding-progress-bar-on-webview-android-tutorials/
final ProgressDialog pd = ProgressDialog.show(this, "", "Please Wait",
true);
final WebView engine = (WebView) findViewById(R.id.webview);
engine.setWebViewClient(new WebViewClient() {
@Override
public void onPageFinished(WebView view, String url) {
if (pd.isShowing() && pd != null) {
pd.dismiss();
}
}
});
engine.loadUrl("http://www.domain.com/");
答案 1 :(得分:1)
之前我曾使用过AsyncTask来做到这一点。使进度对话框显示在onPreExecute中,并在onPostExecute中将其关闭。工作非常好,而且很干净。
http://javatech.org/2011/02/discovering-android-opening-a-progress-dialog-with-asynctask/