Fragments

Training » All Courses » Android » Fragments

[top] Duration

3 hours.

[top] Outline

Android runs on variety of devices, from phones with small screen sizes, to tablets and large-screen TV sets. Fragments in a nutshell represent a smaller part of a user interface that could take a whole screen, or be part of a larger UI. By creating and using fragments, your app can adapt to variety of devices and screen sizes. In this module, you will get a solid overview of fragments and will learn how to design them, develop them, and use them both statically and dynamically. Topics covered include:

  • What is a fragment: an overview and motivation
  • The compatibility package: targeting pre-Honeycomb devices
  • Fragment lifecycle
  • Creating a fragment class
  • Creating a fragment layout
  • Statically including fragments in an activity
  • Dynamically attaching fragments
  • Handling run-time configuration changes
  • Retaining Fragments Across Activity Re-Creation
  • Using Fragments with no Layouts
  • Finding Fragments
  • Fragment Operations
  • Performing Fragment Transactions
  • Managing the Fragment Back Stack
  • Integrating Fragment Action Bar/Options Menu Items
  • Integrating Fragment Action Bar/Options Menu Items (example)
  • Communication Between the Fragment and the Activity
  • Best Practices: Loose Coupling of Activities and Fragments
  • Best Practices: Define Fragment Interfaces to Invoke Activity Behavior
  • Best Practices: The Activity as a Switchboard
  • Advanced Fragment Initialization
  • Implementing Dialogs Using Fragments
  • Using a Fragment-Based Dialog
  • Fragment-Based Preference Management
  • Additional Fragment Subclasses