In chapter 9, we are taught to create a generic class for an activity that all activities will use in order to avoid reusing the same code over and over. This code is used to create an activity hosting a single fragment. My confusion comes later down the line, when we learn to use to dialogs. Now, one activity is hosting two fragments: the fragment originally created by the activity, and a dialog fragment. Doesn’t this conflict with the naming of SingleFragmentActivity? Does the name of that class mean that the activity can only hold a single fragment? Did I miss interpret the name of that class?
It may contain a single fragment, but only one flame at a time, the original fragment is paused until Chapter 10.
SingleFragmentActivity can contain a single fragment in the normal case. If you add fragments dynamically (as we do with the dialog fragment), then the activity can contain multiple fragments.
DialogFragments are a little different than the usual type of fragments that you use. DialogFragments do not exist in your Activity’s layout. There is no spot for them in the layout file. Instead, they float over the top of the Activity and its fragments and views.