【发布时间】:2011-09-09 10:45:25
【问题描述】:
我是Android编程的新手,所以请原谅我的愚蠢问题>,
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.btnDoRegister:
pd = ProgressDialog.show(RegisterActivity.this, "",
"Registering with the server..");
new Thread() {
public void run() {
Looper.prepare();
//(hopefully) thread-safe implementations here
handler.sendEmptyMessage(0);
}
}.start();
if (status == registered) {
//show AlertDialog/Toast here
finish();
} else if (status == notRegistered) {
//show AlertDialog/Toast here
}
break;
}
更令人困惑的是,当我尝试调试它时,LogCat 什么也没有显示,并且一切运行正常(警报/toast 显示为预期)。但是当我尝试正常运行它时,不知何故我觉得它运行得太快并且没有正确显示我的警报/吐司(听起来很愚蠢)。非常感谢您的帮助。
【问题讨论】:
-
k,您在哪个线程中关闭了进度对话框?只显示那个 coe。
标签: android multithreading android-alertdialog progressdialog toast