Android中ProgressDialog自动消失

来源:互联网 发布:mac版qq怎么发送文件 编辑:程序博客网 时间:2024/05/16 02:11

 

主要函数部分代码:

final ProgressDialog proDialog = android.app.ProgressDialog
.show(MainActivity.this, "测试", "2秒后自动消失!");
Thread thread = new Thread() {
public void run() {
try {
sleep(2000);
} catch (InterruptedException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
proDialog.dismiss();// 万万不可少这句,否则会程序会卡死。
}
};
thread.start();

运行结果如下:

0 0