Book Tip: Creating Dynamic UI with Android Fragments
The concept of Fragments was introduced in Android Honeycomb. This was the time when tablets were first introduced to the Android world. Although this feels like a very long time, it was in fact only 2 years ago.
These days most Android developers are familiar with fragments and are likely to have run into some of the problems and pitfalls associated with the technology.
This new book attempts to summarise some of the last 2 years and what we (should) have learned.
For most Android developers Fragments should form part of their daily work. But do we really understand them? Are we aware of fragment lifecycles? Or a more simple question — are we fully aware of all of the possibilites that fragments have to offer?
If you answered no to any of the questions or are a little bit unsure, then this book is for you! It starts with an overview of when to use fragments (and also when not to) and introduces them using an example that we follow throughout the book. The example changes from a simple app into a more advanced one with landscape views, which is later migrated to tablets. This way it changes from a normal layout application into one with fragments.
It not only explains resource folders, but also layout aliases mechanism. This is a great start for new developers.
If you are already familiar with fragments you might want to skip the first part but should pay attention to the the part about lifecycle. It details exactly how lifecycle and associated methods of activities and fragment are bound. The book describes the important differences between onCreate() and onCreateView() especially when it comes to pausing views and what it means in terms of performance for the developer.
The last part of the book covers actionbar navigation examples built with fragments as tabs or dropdown navigation. For me, this is the only negative point in the book — nowadays most people use menu drawer for navigation, but this is completly missing in the book. It would have been great to see this compared to other modes and what you need to change in your app and how it effects your fragments.
Altogther this is an important book. It's not a large book, just a few hundred pages, so a quick read and a quick win.
Title graphics: Packt Publishing