What are Fragments?2:15 with Ben Deitch
The goal of this course is to learn how to use Fragments in Android. In this video we'll learn some of the history of Fragments and get a better idea of what they are.
[MUSIC] 0:00 Hi I'm Ben. 0:04 And in this course, we'll be learning all about fragments. 0:06 But before we talk about fragments, let's take a quick trip back in time. 0:09 The year was 2011. 0:15 We saw Charlie Sheen's very public meltdown, Oprah's last episode, and 0:16 most importantly, we got a new version of Android. 0:21 Honeycomb, Android's first and, so far, only tablet specific update. 0:25 Honeycomb brought tons of new features to make working with tablet UIs a lot easier. 0:31 By far, the biggest of these new features was Fragments. 0:36 With Honeycomb, 0:40 developers could now break up activities into sub-components called fragments. 0:41 Here's an example. 0:46 Let's say we're making an address book. 0:49 We need a list for all of our contacts. 0:51 And when we click on a contact, we see a new screen with more details. 0:53 But how does this look on a tablet? 0:58 Not so good. 1:01 Luckily, with fragments, we can make this look a lot better. 1:02 Instead of doing most of our UI in the activity, we can do it in the fragments. 1:07 We can have a list fragment for our contact list and a details fragment for 1:12 the details page. 1:17 Then, regardless of whether a user is on a phone or 1:18 a tablet, we can display the best UI possible. 1:22 Now that we have a vague notion of what fragments are, 1:26 let's take a look at the project we'll be working on. 1:29 I don't know about you, 1:32 but one of the most-used apps on my tablet is a recipe app. 1:33 So for this course we'll be making a breakfast themed recipe app named 1:37 Smells Like Bacon. 1:42 Here it is in action. 1:44 On a phone we have a list with all the recipes. 1:46 And when we click on a recipe, we get a new screen with two tabs, one for 1:49 ingredients and one for directions. 1:54 On a tablet we have a grid with all the recipes. 1:57 And when we click on a recipe, we get a new screen with 2:01 the ingredients on the left and the directions on the right. 2:04 It's a lot to cover. 2:08 But at the end of this course, 2:10 you should have an excellent understanding of fragments. 2:11
You need to sign up for Treehouse in order to download course files.Sign up