进度条对话框在Android程序中显示不出来,我找不出问题的原因。使用了如下代码来显示进度条对话框:
func{
progressdialog.show();
....
.....
anotherfunction();
listview.setAdapter();
progressdialog.dismiss();
}
当.show() 命令执行以后,进度条对话框就会显示。但是当otherfucntion()方法被调用后,之前显示的进度条对话框会终止吗?编写对话框的一般规则是什么啊?
请求大家的帮忙,谢谢!
显示一个进度条对话框要使用
ProgressDialog progressDialog = ProgressDialog.show(PrintMain.this, "",
"Uploading Document. Please wait...", true);
当你完成这一项,再使用
progressDialog.dismiss();
取消显示进度条对话框 ..
你可以在 AsyncTask类中调用onPreExecute方法来显示进度条对话框,在onPostExecute方法中取消显示。
在活动中加以下代码:
ProgressDialog _progressDialog = ProgressDialog.show(this,"Saving Data","Please wait......");
settintAdater();
private void settingAdater(){
Thread _thread = new Thread(){
public void run() {
Message _msg = new Message();
_msg.what = 1;
YourCalss.this._handle.sendMessage(_msg);
};
};
_thread.start();
}
Handler _handle = new Handler(){
public void handleMessage(Message msg) {
switch(msg.what){
case 1:
_progressDialog.dismiss();
listview.setAdapter();
}
}
}