Reputation:
I am changing a text of a label when the dialog box opens via a button click, what I also want to do is change the text back when the dialog box closes. I do not have any buttons on the dialog and by default user is able to press the back key or tap anywhere outside of the dialog box to close it. (I do not want to add a button). I have been trying for to work this out for a good day now and still for the life of me figure out how it works (Shows what a newbie I am!) I have tried various methods e.g.
but none seems to work, I understand the solution may be simple... I have tried stuff like dismiss etc. too.
I will really appreciate if someone could shed some light on this.
Upvotes: 0
Views: 748
Reputation: 257
You can use an onDismissListener() to set as listener whenever the dialog is closed
Upvotes: 0
Reputation: 2148
Customdialog=new Dialog(this);
Customdialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
@Override
public void onDismiss(DialogInterface dialogInterface) {
//code you want to execute when the dialog is closed
}
});
Hope it helps (:
Upvotes: 1