I\'m trying to make a custom dialog to show a view in this dialog. This is the Builder code:
//Getting the layout
LayoutInflater inflater = (LayoutInflater)
I think a better way may be to call
dismissDialog(DIALOG_ID);
Wouldn't making the AlertDialog a class property defeat the purpose of returning a Dialog from the onCreateDialog()?
Use AlertDialog
instance e.g. mAlertDialog
as a global variable. And call mAlertDialog.dismiss();
inside onClick()
You have to save the AlertDialog to your parent class property, then use something like this:
class parentClass ........ {
private AlertDialog alert=null;
........
public void onClick(View v) {
//Do some stuff
//Here i want to close the dialog
if (parentClass.this.alert!=null)
parentClass.this.alert.dismiss();
}
........
this.alert = builder.create();
this.alert.show();
}
ı am using
public Dialog dialog;
buton_sil.setOnClickListener(new View.OnClickListener() {
@ Override
public void onClick(View v) {
DialogClose();
}
}):
public void DialogClose() {
dialog.dismiss();
}