我想对一个活动做一个密码提示框,所以一旦它有正确的答案,它会关闭对话框,但我无法找到一种方法,当我搜索如何关闭对话框的方式我已经编码了。如何取消alertdialog?
这里是我的代码
final AlertDialog.Builder alert1 = new AlertDialog.Builder(this);
alert1.setTitle("Password");
alert1.setMessage("Please enter your password below and press Ok.");
final EditText input = new EditText(this);
alert1.setView(input);
alert1.setPositiveButton("Ok", new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
String value = input.getText().toString().trim();
((Global) Menu.this.getApplication()).setgPassword(value);
((Global) Menu.this.getApplication()).setgSiteId(strSavedMem1);
LogIn();
}
});
alert1.setNegativeButton("Cancel",new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog, int whichButton) {
System.exit(0);
}
});
alert1.show();
有没有办法关闭这个alertbox?
非常感谢你 – user902080