Summary
This chapter has covered fragments in depth, starting with learning about the fragment lifecycle and the key functions to override in your own fragments. We then moved on to adding simple fragments statically to an app in XML and demonstrating how the UI display and logic can be self-contained in individual fragments. Other options for how to add fragments to an app using a FragmentContainerView
and dynamically adding and replacing fragments were then covered. We then finished with how this can be simplified by using the Jetpack Navigation
component.
Fragments are one of the fundamental building blocks of Android development. The concepts you have learned about here will allow you to build upon them and progress to create increasingly more advanced apps. Fragments are at the core of building effective navigation into your apps in order to bind features and functionality that are simple and easy to use.
The next chapter will explore this area in detail by using established...