Why would I want to use DialogFragments over Regular Fragments in Android?

518 views Asked by At

Surprisingly, I couldn't find any posts regarding this, so here we go:

Why would I want to use a DialogFragment over a simple Fragment in Android? What advantages does the DialogFragment have that I will miss out on if I just use a regular Fragment?

Might be worth mentioning that I intend to have a fully customized view inside it...

Thanks!

2

There are 2 answers

0
Hadi Satrio On BEST ANSWER

A DialogFragment is no other than a Fragment that looks and acts like a Dialog would. So whether or not you want to use it is entirely depended on what do you want to make out of it.

From my experience using DialogFragment, I tend to utilize it as a "detailed" view of a list item. The one that hovers on the list instead of covering it entirely (like a normal Fragment would) so that the user doesn't lose context.

So that's that; you might want to use it wherever you want to show a view which either depend or need to retain its' parent context.

p.s., Yes, you can even put a fully customized view in a DialogFragment.

0
Mimmo Grottoli On

Well, basically you have all features od a Dialog in a fragment. For example the back is handled by the system, you can dismiss the dialog clicking outside the dialog view, you can set the dialog to be not cancellable. And yes, the look and feel is the same of the other dialogs.