Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Android Build a Self-Destructing Message Android App Starting the App Setting Up the Project

Akshay Shivpuri
Akshay Shivpuri
2,917 Points

Fragment layout option

On the page where the Activity name and navigation type are displayed a fragment layout option is also displayed? What is it used for? Probably this option is coming due to the new version of Eclipse and ADT

1 Answer

Nick Edwards
PLUS
Nick Edwards
Courses Plus Student 15,766 Points

Fragments form a part of the UI just like regular activities can, the difference being that a single activity can display multiple fragments on one page (eg. a multi-pane UI) and multiple activities can re-use the same fragment.

Fragments, however, do depend on being embedded in an activity, so you can either use just activities or both activities and fragments. This is why when you create a blank Android project in Eclipse there will be both an activity_main.xml and a fragment_main.xml. The latter is actually what the user will see, while the former is simply used to anchor the fragment to it. You can read more about fragments here.

They were added by default in the newer versions of the ADT for Eclipse - this is why the Android course here doesn't include fragments initially, since the videos were released only months before the ADT was updated.