I have a fragment where I click a button and it opens a dialog(DialogFragment). In this dialog, i have a button that if I press it, I want to dismiss this dialog and open another different dialog(DialogFragment). In this new dialog I want to do something similar, I want to make a button to go back to the previous dialog.
In my navigation graph I have this:
<dialog android:id="@+id/dialog_first" android:name="com.example.dialog.FirstDialog" android:label="first" tools:layout="@layout/myfirstdialog">
<argument android:name="phonenumber" app:argType="string"/>
<action android:id="@+id/action_dialog_first_to_dialog_second" app:destination="@+id/dialog_second"/>
</dialog>
<dialog android:id="@+id/dialog_second" android:name="com.example.dialog.SecondDialog" android:label="second" tools:layout="@layout/myfirstdialog">
<action android:id="@+id/action_dialog_second_to_dialog_first" app:destination="@+id/dialog_second"/>
</dialog>
In my first dialog, I recieve an argument to show it, if I travel to second dialog and come back to first dialog, I want to still have the argument in the dialog,is it needed to pass the argument to second dialog and pass it back then to the first dialog again to keep it or not?
Thats how Im doing it but when I click the button to navigate from the first dialog to the second dialog it only dismiss the dialog.
btnGoToSecondDialog.setOnClickListener{
dismiss()
findNavController().navigate(
FirstDialogDirections.action_dialog_first_to_dialog_second()
)
}
How is the best way to do this? How can I show the second dialog? Is it needed to pass the argument to the second dialog if I go back from the second dialog to the first to still showing the argument?