Skip navigation

Add a fragment with Java

Add a fragment with Java: Building Flexible Android Apps with the Fragments API
Add a fragment with Java: Building Flexible Android Apps with the Fragments API

To add a fragment to an activity programmatically, you need a placeholder in the activity's layout. The most common strategy is to place a FrameLayout object in the location where you want the fragment to appear, and then you can add or replace the fragment at runtime with a fragment transaction. A FrameLayout is a view group that's designed to only have one child object, so it makes the perfect placeholder.

Resume Transcript Auto-Scroll
Skill Level Intermediate
2h 28m
Duration
38,027
Views
Show More Show Less
Skills covered in this course
Developer Mobile Apps Android

Continue Assessment

You started this assessment previously and didn't complete it. You can pick up where you left off, or start over.

Start Your Free Trial Now

Start your free trial now, and begin learning software, business and creative skills—anytime, anywhere—with video instruction from recognized industry experts.

Start Your Free Trial Now