【发布时间】:2014-05-19 21:11:06
【问题描述】:
如下代码所示,如果Progressdialoge存在,我想给它设置一条新消息,3秒后关闭。
在运行时,发生的情况是,旧消息保持设置为 progressdialog 并持续 3 秒,然后 progressdialog 在没有设置新消息的情况下关闭。有什么建议吗?
代码:
if ( (location != null) && (mProgreeDialoge != null) ){
mProgreeDialoge.setMessage(PROGRESS_DIALOGUE_MSG01);
try {
Thread.sleep(3000);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
更新:
if ( (location != null) && (mProgreeDialoge != null) ){
mProgreeDialoge.setMessage(PROGRESS_DIALOGUE_MSG01);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
// TODO Auto-generated method stub
mProgreeDialoge.dismiss();
}
}, FREEZE_PROGRESS_DIALOGUE_TIME);
【问题讨论】:
标签: java android multithreading