1

我想知道当用户应用程序进入前台时处理要出现的对话框的最佳方法。

我的情况就像在进度对话框或正常警报对话框中显示一些消息并且我按下主页按钮将应用程序带到后台。当我回到屏幕时,进度对话框或警报对话框应该在屏幕上持续存在。

我尝试将此块放在 onStart() 中,但它显示了 NULL 指针异常。

onStart(){
if alertdialog.isShowing() alertdialog.show();
}
4

1 回答 1

2
if(alertdialog == null){
  // create your dialog here and then show it
} else if (!alertdialog.isShowing()) {
  alertdialog.show();
}
于 2011-03-08T08:58:45.833 回答