0

In my app, I display a custom Dialog (using DialogFragment), which on certain action causes another custom Dialog to be shown (using another DialogFragment). This all works fine. However when the "child" dialog is closed, I want to return to the parent dialog (which is closed/hidden when the child is displayed).

I do not want just display another instance of the same dialog, as I need to maintain states and behaviours of the parent prior to the child being open. Therefore I need to re-display physically the same dialog.

I can't seem to find a way of doing so.

Aleks G
  • 56,435
  • 29
  • 168
  • 265
  • ... don't close the "parent" before showing the "child"? – Phantômaxx Dec 18 '15 at 16:26
  • @FrankN.Stein I don't close it - Android automatically closes it without giving any option not to. – Aleks G Dec 18 '15 at 16:42
  • Because I normally close a DialogFragment after using it, by explicitly calling the `dismiss()` method. – Phantômaxx Dec 18 '15 at 16:45
  • 1
    Yes, I do that as well when working with one fragment only. However android automatically closes all other dialogs when displaying a new one (I believe full screen dialogs are an exception, but may be wrong). – Aleks G Dec 18 '15 at 16:46
  • I didn't know that. I'll leave the comments because I find this small discussion useful to other people as well. – Phantômaxx Dec 18 '15 at 16:48
  • 1
    Hehe :) Interestingly, I just found [my own question](http://stackoverflow.com/questions/14566593/displaying-second-dialog-from-button-click-in-first-dialog-closes-first-dialog) from three years ago, asking pretty much the same thing :) – Aleks G Dec 18 '15 at 16:49

1 Answers1

0

Coming back to it as I now got a solution that seems to work. Apparently, using dialog directly will close the previous dialog when a new one is opened. Yet, when using DialogFragment, the previous fragment stays on screen when the new fragment is displayed. Then when the dialog on the new fragment is closed the previous fragment is still visible - exactly what I need.

Aleks G
  • 56,435
  • 29
  • 168
  • 265