public void MsgBox(String title, String msg){
AlertDialog.Builder dlgAlert = new AlertDialog.Builder(this);
dlgAlert.setMessage("The message");
dlgAlert.setTitle("Titel");
dlgAlert.setPositiveButton("OK", null);
dlgAlert.create().show();
}
这是我正在使用的方法,我不明白它有什么问题。我什至将 null
替换为您要添加的通用代码,但该框仍然不会弹出。有什么建议吗?
最佳答案
尝试:
new AlertDialog.Builder(this.getContext());
也许您没有从实际上是 Activity 的类中调用它
关于java - 警报对话框不显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28862235/