1 00:00:00,240 --> 00:00:02,080 Now that we've finished our adapter, 2 00:00:02,080 --> 00:00:04,870 let's head over to our list fragment's layout file. 3 00:00:04,870 --> 00:00:06,670 And give our adapter something it can work with. 4 00:00:07,680 --> 00:00:11,370 Let's head over to the Text tab and start by deleting the TextView. 5 00:00:13,680 --> 00:00:16,020 Then, let's add in a RecyclerView to hold our list. 6 00:00:20,290 --> 00:00:24,240 And since we waned to take up the whole screen, let set its width and 7 00:00:24,240 --> 00:00:25,510 height to match parent. 8 00:00:27,100 --> 00:00:30,400 We also wanna be able to access this view from code. 9 00:00:30,400 --> 00:00:38,909 So let's give it an ID, Of listRecyclerView. 10 00:00:40,560 --> 00:00:44,140 Then I'll add a backslash here and that will end the tag. 11 00:00:45,370 --> 00:00:46,800 Great job. 12 00:00:46,800 --> 00:00:50,040 Now it's a jump to our list fragment class and hook up a recycler view. 13 00:00:52,370 --> 00:00:55,520 First we'll need to get a reference to our recycler view. 14 00:00:55,520 --> 00:00:59,170 Let's add some space below the inflater and 15 00:00:59,170 --> 00:01:03,460 create a new recycler view named recyclerView. 16 00:01:04,850 --> 00:01:13,342 And let's set it equal to view.findViewById.ListRecyclerView. 17 00:01:15,202 --> 00:01:17,310 And then use ALT enter to add the cast. 18 00:01:20,080 --> 00:01:24,260 Next, let's create a new variable for our ListAdapter as well. 19 00:01:24,260 --> 00:01:27,190 But first I'm going to give myself a little more room on the right. 20 00:01:29,751 --> 00:01:32,540 Back to the List Adapter. 21 00:01:35,700 --> 00:01:40,460 ListAdapter, let's name it ListAdapter and set it equal to new ListAdapter. 22 00:01:42,440 --> 00:01:46,605 Now that we have our ListAdapter let's attach it to a recyclerView by calling 23 00:01:46,605 --> 00:01:51,840 recyclerView.setAdapter and passing it on our listAdapter. 24 00:01:54,390 --> 00:01:57,580 Next we need to set a layout manager for our recyclerView. 25 00:01:58,780 --> 00:02:03,710 Remember the layout manager is responsible for determining where to place the views, 26 00:02:03,710 --> 00:02:06,410 as well as when to reuse a view that's no longer visible. 27 00:02:08,150 --> 00:02:11,230 To make our recyclerView act like a vertical list, 28 00:02:11,230 --> 00:02:14,140 we can use the built in linear layout manager class. 29 00:02:15,190 --> 00:02:19,770 Let's create a new variable for our layout manager named LayoutManager. 30 00:02:23,670 --> 00:02:27,680 And let's set it equal to new LinearLayoutManager. 31 00:02:29,010 --> 00:02:31,610 And for the context let's pass in getActivity. 32 00:02:33,690 --> 00:02:37,450 Fragments always have access to their activity through the getActivity method. 33 00:02:38,970 --> 00:02:40,630 We also could have used to get context. 34 00:02:41,990 --> 00:02:44,040 Now that we've got our layout manager. 35 00:02:44,040 --> 00:02:47,425 Let's attach it to our recyclerView By calling recycler 36 00:02:47,425 --> 00:02:53,320 view.setlayoutmanager and passing it in our layout manager. 37 00:02:56,160 --> 00:02:57,130 That should do it. 38 00:02:57,130 --> 00:02:59,341 Let's test the app and see what happens. 39 00:03:07,200 --> 00:03:07,940 Nice. 40 00:03:07,940 --> 00:03:11,740 We've got a list of all our recipes including pictures, and it scrolls up and 41 00:03:11,740 --> 00:03:12,250 down too. 42 00:03:14,120 --> 00:03:15,520 Perfect. 43 00:03:15,520 --> 00:03:18,180 But this white background is awfully bright. 44 00:03:18,180 --> 00:03:23,060 Let's change this By opening our styles.xml file and 45 00:03:23,060 --> 00:03:28,040 the resources directory, under the values directory and 46 00:03:28,040 --> 00:03:35,410 changing the parent theme to just the standard, theme.appcompat. 47 00:03:35,410 --> 00:03:36,730 Now if we run the app again. 48 00:03:40,820 --> 00:03:41,980 Welcome to the dark side.