danb
danb

Reputation: 10379

Why does AlertDialog.Builder not have setOnDismissListener or setOnShowListener methods?

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.

Upvotes: 5

Views: 6028

Answers (2)

Amol Desai
Amol Desai

Reputation: 927

From API level 17. you can use setOnDismissListener (DialogInterface.OnDismissListener onDismissListener) method

Upvotes: 1

coder_For_Life22
coder_For_Life22

Reputation: 26981

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;

Upvotes: 7

Related Questions