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 Using Fragments for Tabs Modifying Fragments from the Template

Hasan Nagaria
Hasan Nagaria
4,855 Points

General logic and thought process help

Ben briefly showed the example of gmail for example saying the list of the emails was one fragment, and when you clicked on an email it would take you to the email which is another fragment but they are BOTH part of the same activity. This example makes sense to me about reusing the same real estate etc but i dont get how/what we are trying to accomplish in our project. Im getting confused between tabs/fragments/activities and what holds what data and yeah.

So one tab is inbox the other is friends. but what does that mean for fragments, for example I know fragments are like small chunks i can play around place together, recycle in an activity. So what happens when i go on the friends tab? What part of what I see is a fragment?

2 Answers

Seth Kroger
Seth Kroger
56,413 Points

Think of a "tab" as a tabbed index card. The tabs of the card let you select and see which one is in front, and the card's body contains the content. Here, each card body is represented by a Fragment. So when you select the Friends tab, it brings the FriendsFragment front and center displaying your list of friends.

Hasan Nagaria
Hasan Nagaria
4,855 Points

So are both the tabs part of the same activity? And each tab allows me to view different fragments?

Seth Kroger
Seth Kroger
56,413 Points

Yes and yes. These tabs are pretty much the same as browser tabs. Each tab is part of the same window and each tab allows you to view a different site, much like in Android each tab is part of the same activity and lets you view a different fragment.