有的时候,我们可能在activity类中调用非activity类中的方法,并需要在非activity类方法中定义AlertDialog对话框,怎么办呢:
1.一般情况是在activity类中定义
AlertDialog
,如下代码;
new AlertDialog.Builder(self)
.setTitle("确认")
.setMessage("确定吗?")
.setPositiveButton("是", null)
.setNegativeButton("否", null)
.show();
2.在非
activity类中定义AlertDialog: