我对Android编程非常陌生,所以请原谅我这个愚蠢的问题>,<正如标题所说,我想在我的ProgressDialog完成后立即显示一个AlertDialog/Toast。我怎样才能以正确的方式做到这一点呢?注意:我的处理程序只是解除ProgressDialog (pd.dismissDialog())。
@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什么也没有显示,一切都运行得很好(警报/吐司显示如预期)。但当我试图正常运行它时,不知何故我觉得它运行得太快了,并且没有正确地显示我的警报/吐司(听起来很愚蠢)。非常感谢你的帮助。
发布于 2011-09-09 18:57:39
在处理程序的handleMessage方法中显示AlertDialog/Toast会更合适,
static Handler handler = new Handler() {
public void handleMessage(Message msg) { ... }};
https://stackoverflow.com/questions/7360477
复制相似问题