Reputation: 1847
Basically Dialogs inactivates the activity at the background. So the DialogFragment
does the same with increased complexity. So why should one go for DialogFragment
though various subclasses of Dialog
are available.
Upvotes: 16
Views: 11552
Reputation: 3361
FragmentDialog is a fragment that can be:
used as fragment, e.g.:
FragmentTransaction trans = getSupportFragmentManager().beginTransaction();
trans.add(R.id.navigation_fragment, mFriendFragment);
trans.commit();
used as dialog, e.g.:
FragmentManager fm = getFragmentManager();
UnsubscribeTabletFragment fragment = new UnsubscribeTabletFragment();
fragment.show(fm, "dialog");
So, if you have a fragment, and the fragment sometimes works as fragment, sometimes works as dialog, then you should use this one.
Upvotes: 4
Reputation: 594
when u have a dynamic layout in your android app using fragment already, then u need to use it with/in your dialog from an action button click or other click, so this time dialogFragment is more convenient then the normal dialog.
Upvotes: 1
Reputation: 68187
Fragments
are used with in your activity, but to present a fragment as dialog (window) using FragmentTransaction
and followup with fragment's life-cycle, you need to use DialogFragment
. However, you may do use simple Dialog
too, but then it has nothing to do with the fragment's life-cycle.
As per google docs:
A DialogFragment can still optionally be used as a normal fragment, if desired. This is useful if you have a fragment that in some cases should be shown as a dialog and others embedded in a larger UI.
Upvotes: 8
Reputation: 1639
DialogFragment permits to reuse so part of dialog on your app. Just like fragments do it for your layouts.
Here you have a good article about DialogFragment: http://android-developers.blogspot.fr/2012/05/using-dialogfragments.html
Upvotes: 3