Chapter 19. Using Multiple Fragments
Now that we have discussed the principals of MVC as well as seen how to implement a Fragment, we can take things a stage further. You will learn how to separate the data layer using a Java singleton and then we will see how Fragments can communicate with each other.
Once we have achieved both of these things, we can implement our first multi-Fragment, orientation-aware app that will put everything we know so far into practice.
Note
In this chapter, to save digital ink, I will stop giving specific instructions on how to make classes and layout files. As a reminder, to create a new class, right-click on the folder that contains all the .java
files and navigate to New | Class. Type the name and click on OK. To create a new layout file, right-click on the layout folder and navigate to New | Resource layout file.
In short, we will do the following in this chapter:
- Explore Java singletons to implement the data layer
- Implement inter-Fragment communication...