I'm working on a little program, and I need to add a custom dialog that passes some info to the calling acitivity when it closes. I extended the dialog class, and when I try to capture the custom dialog when it closes,using an onDismiss listener, it never reaches it because I used a custom dialog.
This is part of my activity -
.
.
.
attributes customizeDialog = new attributes(con,position,pick.getLastVisiblePosition());
customizeDialog.show();
(The attributes being the name of the class that extends the dialog class).
Here is the event listener I set up when the dialog finishes -
customizeDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialog) {
Log.v("LOG_CAT",attributes.selectedIndexes.get(0) + " " + attributes.selectedIndexes.get(1) + " " + attributes.selectedIndexes.get(2) + " " + attributes.selectedIndexes.get(3) + " " + attributes.selectedIndexes.get(5) + " ");
}
});
I know i'm doing it wrong,I just don't know how to fix it.
I would really appreciate any help with this problem.
Thanks!
If you are using custom dialog and can't dismiss it, try below code. It worked for me.
One thing to remember is that an
OnDismissListener
is listening for the dismiss of the child processes. The parent of your customer dialog needs theonDismissListener
, not the dialog itself."Interface used to allow the creator of a dialog to run some code when the dialog is dismissed."
To add dialog inside CustomDialog class:
I tend to have my activity implement listeners like this...
You could have your calling activity implement a custom listener interface that is called when the dialog closes:
This is especially useful if you want to send stuff back to the caller at any other time besides on dismissal.
And if you want to have some sort of saving inside the dialog, again, you have to use
onDicmissListener
since for custom dialogsonDismiss
is not called by default: