I'm trying to create an app with a navigation bar. The navigation bar will have options to go to, such as the SettingsActivity
which will have preferences.
For navigation bars, I know you're meant to switch between fragments in a MainActivity
to switch between as the user clicks on the different fragments.
However, I need different fragments within my Settings page so I think that I need to use an activity (i.e SettingsActivity
) for each of the different headers. My settings activity needs to extend from AppCompatPreferenceActivity
but if it were a fragment, I would have to extend it from Fragment
as well.
But because Android Studio does not support Nested Fragments I don't know what I should do.
Thank you
If you create a SettingsActivity via android studio you will notice that it is using some fragments that extend PreferenceFragment
. This class is deprecated thus you should use (as it is stated in the documentation) the class android.support.v7.preference.PreferenceFragmentCompat
You can create a Fragment that extends android.support.v7.preference.PreferenceFragmentCompat
and show it manually.
Or You can create a fragment and show a list of desired settings and show the fragments you created using the method getChildFragmentManager()