Building Flexible Android Apps with the Fragments API

Author

Released

9/1/2016

One of the most common challenges Android developers face is the variation in screen sizes among the thousands of phones, tablets, and other devices that run Android. The Fragments API (introduced in Android 3.0) provides an elegant solution. With fragments, you can build flexible layouts that adapt to any screen size—and do so dynamically, at runtime. In this course, David Gassner shows how to define a layout, add fragments to activities with Java or XML, create alternative layouts for different screen sizes, and use resource folder names to detect and select the right layout. He also shows you how to communicate between activities and fragments with arguments and callback methods, and use fragments to manage dialogs and shared preferences.

Topics include:

Configuring Android Studio

Understanding fragments

Creating a fragment class and layout

Adding and removing fragments with Java

Creating layouts for multiple screens

Understanding arguments and callback methods

Passing arguments to a fragment

Choosing layout at runtime

Displaying dialogs with fragments

Using fragments for managing dialogs, shared preferences, and more

Skill Level Intermediate

2h 26m

Duration

84,526

Views

Show MoreShow Less

- Hi, my name is David Gassner.Welcome to this course on using the Android Fragments APIto build flexible apps that adapt to different screen sizes.Working in Android Studio,I'll first introduce you to the basic concept of fragments.I'll describe how to define a fragment's layoutand how to add it to an activity with XML or Java.I'll then show you how to define multiple layoutsfor different screens,how to use resource folder names to detect screen sizesand select layouts at runtimeand how to pass data back and forthbetween activities and fragmentswith arguments and callback methods.

I'll also describe other uses of fragmentsto manage dialogs,pages managed in the view page or container,and shared preferences.The Fragments API is an important partof any Android developers toolkit.I hope this course helps you get started,building apps that look great on a wide variety of devices.