在程序加载过程中显示ProgressDialog 对话框

时间:2023-01-10 21:40:39
    private ProgressDialog mProgressDlg = null;

    @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
//---开始显示ProgressDialog对话框
mProgressDlg = ProgressDialog.show(this, "提示", "正在在加载", true);
//----通过线程模拟加载任务
new Thread(){
public void run() {
try {
Thread.sleep(5000);
//---加载完成后必须Progress 对话框
mProgressDlg.dismiss();
}
catch(Exception ex) {
ex.printStackTrace();
}
}
};
}