我想對一個活動做一個密碼提示框,所以一旦它有正確的答案,它會關閉對話框,但我無法找到一種方法,當我搜索如何關閉對話框的方式我已經編碼了。如何取消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