【发布时间】:2013-09-13 12:20:16
【问题描述】:
我正在我的应用程序中创建一个进度对话框。下面是我的代码...
ProgressDialog dialog = ProgressDialog.show(TabViewLayout.this, "", "Logout...");
dialog.setProgressStyle(ProgressDialog.STYLE_SPINNER);
dialog.isIndeterminate();
new Thread() {
public void run() {
try {
sleep(5000);
}
catch (Exception e) { }
}
}.start();
Handler handler = new Handler();
handler.post(new Runnable(){
public void run(){
dialog.dismiss();
}
});
我必须做的是,我必须在我的应用程序中延迟 5 秒以进行某些进程。使用上面的代码,进度对话框出现在屏幕上,但微调器没有旋转。我希望它处于旋转模式 5 秒。需要做什么?
【问题讨论】:
-
使用倒数计时器代替线程睡眠。您开始显示进度条并启动一个线程,然后您关闭。