I wanted to do a password alert box on an activity so once it has the correct answer it closes the dialog box but I cant seem to find a way when searching of how to close a dialog box the way I have coded it anyway.
Here is my code
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();
Is there a way to close this alertbox?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With