Android – Why does AlertDialog.Builder not have setOnDismissListener or setOnShowListener methods

androidandroid-alertdialog

I want to use the fluid interface of AlertDialog.Builder but when I get to the point of adding my DismissListener and ShowListener I have to break out and add it to the dialog object after I do my create() on the builder. Does anyone know why they're not on there? I can't extend it because of the private P member… It's not the end of the world or anything, I'm just curious why it's not there.

Best Answer

Have You Tried this method..

AlertDialog dlg = builder.create();
lg.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(final DialogInterface dialog) {
//Do some work
}
});
return dlg;