我想知道处理用户应用程序出现在前台时出现的对话框的最佳方法。
如果我在进度对话框或正常警报对话框中显示一些消息,然后我按下主页按钮将应用程序转至后台,我的场景就是这样。当我回到屏幕时,进度对话框或警报对话框应该会一直显示在屏幕上。
我尝试将此 block 放在 onStart() 中,但它显示 NULL 指针异常。
onStart(){
if alertdialog.isShowing() alertdialog.show();
}
最佳答案
if(alertdialog == null){
// create your dialog here and then show it
} else if (!alertdialog.isShowing()) {
alertdialog.show();
}
关于android - 当应用程序进入前台时,使对话框持久显示在屏幕上的最佳方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5230216/