小编Eng*_*mex的帖子

如何关闭Android alertdialog

我正在开发一个测验,我需要用户在继续之前回答所有问题.当用户没有回答所有问题时,我会显示一个简单的警报,告知他或她.问题是无论我做什么我都无法关闭alertdialog.为什么dialog.cancel不工作?`这是代码:

AlertDialog.Builder ad = new AlertDialog.Builder(this);  
ad.setTitle("Unanswered Questions");  
ad.setMessage("You have not answered all the questions.");   
ad.setPositiveButton("OK", new DialogInterface.OnClickListener() {  
   public void onClick(DialogInterface dialog, int id) {  
     dialog.cancel(); 
}  
});  
ad.show(); 
Run Code Online (Sandbox Code Playgroud)

android

38
推荐指数
6
解决办法
10万
查看次数

标签 统计

android ×1