Skip to content Skip to sidebar Skip to footer

Correct Way To Remove A Dialogfragment: Dismiss() Or Transaction.remove()?

I still have a problem due to a DialogFragment used on my main activity. I am currently using this code to remove it: FragmentTransaction transaction = getFragmentManager().beginTr

Solution 1:

DialogFragment.dismiss() is the correct way. From the documentation:

Dismiss the fragment and its dialog. If the fragment was added to the back stack, all back stack state up to and including this entry will be popped. Otherwise, a new transaction will be committed to remove the fragment.

Solution 2:

For showing Dialog Fragment dialogFragment.show(transition,FocusDialogFragment.TAG);

For dismissing dialog fragment by dialogFragment.dismiss();

Post a Comment for "Correct Way To Remove A Dialogfragment: Dismiss() Or Transaction.remove()?"