我正在尝试编写代码,例如,可以在5秒后显示AlertDialog
消息,在这5秒内我想显示ProgressDialog
。
我编写了代码但ProgressDialog
没有解雇。
这是源代码:
ringProgressDialog = ProgressDialog.show(CameraPreview.this,
"Please wait ...", "Downloading Image ...", true);
ringProgressDialog.setCancelable(false);
ringProgressDialog.hide();
AsyncTask<Void, Void, Void> task = new AsyncTask<Void, Void, Void>() {
@Override
protected void onPreExecute() {
ringProgressDialog.show();
}
@Override
protected Void doInBackground(Void... arg0) {
try {
diaBox1.show();
Thread.sleep(5000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return null;
}
@Override
protected void onPostExecute(Void result) {
if (ringProgressDialog != null) {
ringProgressDialog.dismiss();
// b.setEnabled(true);
}
}
};
task.execute((Void[]) null);