1 00:00:00,110 --> 00:00:04,030 We've just finished the ingredients fragment can you guess what's up next? 2 00:00:04,030 --> 00:00:06,550 And that's right the directions fragment. 3 00:00:06,550 --> 00:00:09,160 And if we take a look at the mock ups it doesn't look like there's 4 00:00:09,160 --> 00:00:10,880 anything new here. 5 00:00:10,880 --> 00:00:14,510 So if you think you can handle finishing up the directions fragment, go ahead and 6 00:00:14,510 --> 00:00:15,860 pause me and give it a shot. 7 00:00:17,110 --> 00:00:20,540 If you'd rather follow along as I finish up the directions fragment. 8 00:00:20,540 --> 00:00:21,880 Then here we go. 9 00:00:21,880 --> 00:00:22,610 Let's start. 10 00:00:22,610 --> 00:00:26,080 But updating fragment directions dot X.M.L.. 11 00:00:26,080 --> 00:00:26,630 First. 12 00:00:26,630 --> 00:00:27,620 Well delete the text view. 13 00:00:29,520 --> 00:00:30,060 Then. 14 00:00:30,060 --> 00:00:33,476 Will give our linear layout an id of directions layout. 15 00:00:33,476 --> 00:00:35,948 Android. 16 00:00:35,948 --> 00:00:42,460 Id directions layout. 17 00:00:42,460 --> 00:00:44,980 Lastly. 18 00:00:44,980 --> 00:00:47,280 Let's add a scroll view around our linear layout. 19 00:00:47,280 --> 00:00:48,858 Just like we did in the previous video. 20 00:00:48,858 --> 00:00:52,065 Scroll view. 21 00:01:03,492 --> 00:01:09,702 Give it the same width and height, and a copy of the closing tag or 22 00:01:09,702 --> 00:01:13,502 cut the closing tag down to the bottom. 23 00:01:16,736 --> 00:01:17,870 Nice. 24 00:01:17,870 --> 00:01:20,680 Now let's switch over to our ViewPagerFragmentClass and 25 00:01:20,680 --> 00:01:24,220 pass an index we need to our directions fragment. 26 00:01:24,220 --> 00:01:27,480 We can do this and the same way as we did for our ingredients fragment. 27 00:01:28,890 --> 00:01:31,840 Let's copy this bundle bit excluding the bundle keyword, 28 00:01:31,840 --> 00:01:34,850 and then paste it below are directions fragment. 29 00:01:37,100 --> 00:01:40,980 Then let's replace Ingredients fragment with directions fragment. 30 00:01:44,570 --> 00:01:49,119 And cool, all that's left now are the changes to the directions fragment class. 31 00:01:51,880 --> 00:01:54,460 Let's start by retrieving the index argument 32 00:01:54,460 --> 00:01:56,765 into a new int variable named index. 33 00:01:56,765 --> 00:02:02,467 and index equals getArguments.getInt 34 00:02:02,467 --> 00:02:08,660 ViewPagerFragment.KEY_RECIPE_INDEX. 35 00:02:08,660 --> 00:02:13,270 Then, below where we set our view, let's create a new linear layout variable for 36 00:02:13,270 --> 00:02:14,288 our directions fragment. 37 00:02:14,288 --> 00:02:19,230 >> [SOUND] >> Linear layout. 38 00:02:19,230 --> 00:02:22,330 Call it linear layout equals 39 00:02:22,330 --> 00:02:27,288 view dot findview I D R dot I D dot directions layout. 40 00:02:27,288 --> 00:02:30,110 And then Alt+Enter to add the cast. 41 00:02:32,230 --> 00:02:36,180 And then below that, let's create a string array to hold the directions for 42 00:02:36,180 --> 00:02:36,834 this recipe. 43 00:02:36,834 --> 00:02:41,633 String array named directions 44 00:02:41,633 --> 00:02:46,638 equals recipes.directions. 45 00:02:46,638 --> 00:02:53,980 At position [index].split. 46 00:02:53,980 --> 00:02:56,600 And split based on where the back take character is. 47 00:02:58,280 --> 00:03:02,230 Now that we've got the directions layout and the directions themselves. 48 00:03:02,230 --> 00:03:06,070 This class doesn't really differ too much from ingredients fragment. 49 00:03:06,070 --> 00:03:09,610 So for the rest of this let's just copy and paste from ingredients fragment. 50 00:03:10,680 --> 00:03:12,551 Let's start with the variables. 51 00:03:23,035 --> 00:03:25,329 Then let's copy over the rest of the onCreatView method. 52 00:03:27,100 --> 00:03:29,017 Starting with mCheckBoxes, 53 00:03:35,070 --> 00:03:37,691 And replace Ingredients with directions. 54 00:03:39,895 --> 00:03:42,417 And finally, let's copy over the setUpCheckBoxes, and 55 00:03:42,417 --> 00:03:43,915 on savedInstanceStateMethods. 56 00:03:54,580 --> 00:03:57,759 And change ingredients to directions here, as well. 57 00:04:14,698 --> 00:04:16,090 That should do it. 58 00:04:16,090 --> 00:04:17,340 Now let's test the app. 59 00:04:17,340 --> 00:04:20,834 And hopefully will see some directions to go along with our ingredients. 60 00:04:30,365 --> 00:04:31,140 Perfect. 61 00:04:31,140 --> 00:04:35,760 Now I can really start my morning right with a nice delicious muffin.