我正在开发一个问答游戏,需要用户回答全部问题后才能继续。当用户没有回答所有问题时,我会显示一个简单的提示框告知用户。但问题是,无论我做什么,都不能让提示框关闭。为什么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();