

You can add your fragment to the activity's view hierarchy either byĭefining the fragment in your activity's layout file or by defining aįragment container in your activity's layout file and then So if you're already subclassing AppCompatActivity to provide backwardĬompatibility in your app, then you do not need to change your activity Generally, your fragment must be embedded within an AndroidXĬontribute a portion of UI to that activity's layout. You can use PreferenceFragmentCompat toĬreate a settings screen for your app. PreferenceFragmentCompat Displays a hierarchy of See Displaying dialogs with DialogFragmentįor more details. Using this class to create a dialog is a goodĪlternative to using the dialog helper methods in theĪutomatically handle the creation and cleanup of the Dialog. The Fragment library also provides more specialized fragment base classes: DialogFragment Displays a floating dialog. Class ExampleFragment : Fragment(R.layout.example_fragment)
