Building Flexible Android Apps with the Fragments API with Java
2h 27mIntermediate2016-09-01
Authors

David Gassner
Author of 60+ video-based training courses for software developers
Course details
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.
Learning objectives
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
Learning objectives
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
Skills covered
Android DevelopmentAndroidMobile DevelopmentGoogleProject
Concepts
0. Introduction
- 01 - Welcome
- 02 - What you should know
- 03 - Using the exercise files
1. Getting Started
- 04 - Configure Android Studio for this course
- 05 - The fragmented market of Android devices
- 06 - Adapting to screen sizes and densities
- 07 - Understanding fragments
- 08 - Create an app with a fragment
2. Display Fragments in Activities
- 09 - Create a fragment class and layout
- 10 - Display a fragment with XML
- 11 - Explore the FragmentTransaction class
- 12 - Add a fragment with Java
- 13 - Remove a fragment with Java
- 14 - The lifecycle of a fragment
- 15 - Trace lifecycle events with LogCat
3. Manage Fragments at Runtime
- 16 - Pass arguments to a fragment
- 17 - Manage arguments with a factory method
- 18 - Measure screen with Java
- 19 - Detect screen with resource selectors
- 20 - Choose layout at runtime
4. Communication between Fragments and Activities
- 21 - Java interfaces and callback methods
- 22 - Define interface with callback methods
- 23 - Send a message from a fragment
- 24 - Send parcelable objects to a fragment
- 25 - Display data lists in fragments
5. Display Dialogs with Fragments
- 26 - Wrap an alert dialog in a fragment
- 27 - Display a custom dialog
- 28 - Pass arguments to the dialog
- 29 - Use callback methods in a dialog
6. Other Uses of Fragments
- 30 - Create a fragment for ViewPager
- 31 - Create a ViewPager adapter
- 32 - Manage back button with ViewPager
- 33 - Manage shared preferences with fragments
Conclusion
- 34 - Next steps
Related courses
Related learn paths
- Prepare for the Google Associate Android Developer Certification
- Become an Android Mobile App Developer
- Advance Your Skills as a Django Developer
- Elevating C# Skills: Building Robust Applications
- Getting Started with Agile Software Development
- Develop Your Skills in Agile Software Development
- Finding and Succeeding in Remote Work
- Building Adaptability in the Age of AI