You are previewing Android Fragments.
O'Reilly logo
Android Fragments

Book Description

Android Fragments is a 100-page quick start accelerated guide to learning and quickly using Android fragments. You'll learn how to code for fragments; deal with config changes; code for regular vs. fragmented dialogs; work with preferences and saving state; work with the compatibility library; and handle advanced async tasks and progress dialogs.

After reading and using this book, which is based on material from the best-selling Pro Android, you'll be an Android UI savant. At the very least, your apps' user interfaces and event handling will be more competitive and better performing, especially for tablet-optimized UIs and events.

Table of Contents

  1. Cover
  2. Title
  3. Copyright
  4. Dedication
  5. Contents at a Glance
  6. Contents
  7. About the Authors
  8. About the Technical Reviewer
  9. Acknowledgments
  10. Introduction
  11. Chapter 1: Fragments Fundamentals
    1. What Is a Fragment?
      1. When to Use Fragments
      2. The Structure of a Fragment
      3. A Fragment’s Life Cycle
      4. Sample Fragment App Showing the Life Cycle
    2. FragmentTransactions and the Fragment Back Stack
      1. Fragment Transaction Transitions and Animations
    3. The FragmentManager
      1. Caution When Referencing Fragments
      2. Saving Fragment State
      3. ListFragments and <fragment>
      4. Invoking a Separate Activity When Needed
      5. Persistence of Fragments
    4. Communications with Fragments
      1. Using startActivity() and setTargetFragment()
    5. References
    6. Summary
  12. Chapter 2: Responding to Configuration Changes
    1. The Default Configuration Change Process
      1. The Destroy/Create Cycle of Activities
      2. The Destroy/Create Cycle of Fragments
      3. Using FragmentManager to Save Fragment State
      4. Using setRetainInstance on a Fragment
    2. Deprecated Configuration Change Methods
    3. Handling Configuration Changes Yourself
    4. References
    5. Summary
  13. Chapter 3: Working with Dialogs
    1. Using Dialogs in Android
    2. Understanding Dialog Fragments
      1. DialogFragment Basics
      2. DialogFragment Sample Application
    3. Working with Toast
    4. References
    5. Summary
  14. Chapter 4: Working with Preferences and Saving State
    1. Exploring the Preferences Framework
      1. Understanding CheckBoxPreference and SwitchPreference
      2. Accessing a Preference Value in Code
      3. Understanding ListPreference
      4. Understanding EditTextPreference
      5. Understanding MultiSelectListPreference
      6. Updating AndroidManifest.xml
      7. Using PreferenceCategory
      8. Creating Child Preferences with Dependency
      9. Preferences with Headers
      10. PreferenceScreens
    2. Dynamic Preference Summary Text
      1. Saving State with Preferences
      2. Using DialogPreference
    3. Reference
    4. Summary
  15. Chapter 5: Using the Compatibility Library for Older Devices
    1. It All Started with Tablets
    2. Adding the Library to Your Project
      1. Including the v7 Support Library
      2. Including the v8 Support Library
      3. Including the v13 Support Library
      4. Including Just the v4 Support Library
    3. Retrofitting an App with the Android Support Library
    4. References
    5. Summary
  16. Chapter 6: Advanced AsyncTask and Progress Dialogs
    1. Introducing the AsyncTask
    2. Implementing a Simple AsyncTask
      1. Implementing Your First AsyncTask
      2. Calling an AsyncTask
      3. Understanding the onPreExecute() Callback and Progress Dialog
      4. Understanding the doInBackground() Method
      5. Triggering onProgressUpdate() through publishProgress()
      6. Understanding the onPostExecute() Method
      7. Upgrading to a Deterministic Progress Dialog
    3. AsyncTask and Thread Pools
    4. Issues and Solutions for Correctly Showing the Progress of an AsyncTask
      1. Dealing with Activity Pointers and Device Rotation
      2. Dealing with Managed Dialogs
      3. Testing Scenarios for a Well-Behaved Progress Dialog
      4. Using a Retained Fragment and a Progress Dialog
      5. Exploring Key Code Snippets
    5. References
    6. Summary
  17. Index