‫Now we need to link the data source, which is an array list of sport objects with the UI, which is
‫the Recyclerview and Cardview.
‫I'll go to the main activity and I'll create instance from Recyclerview cycler view Alt+ enter to import
‫Recyclerview class and I need to initialize this recyclerview.
‫Then I need the data source.
‫I start by private list of sport model class Alt+.
‫Enter to import the list class.
‫I name it as sport list.
‫I'll initialize it here.
‫Sport list equal to new array list.
‫Now I need to add sport items to this array list.
‫I start by a sport object S1 equal to new sport and for the sport I need to pass the name and the image.
‫You can see the constructor accepts a string and an integer variables starting by the name, which is
‫football, and I'll pass the image from the drawable folder.
‫Of course, I'll continue by creating the other sports objects.
‫And here we go.
‫These are the sport objects.
‫I'll add them to the sport list.
‫So sport list dot add method S1, S2 until S5.
‫Now our adapter view, which is the recycler view, is ready and the data source which is export list
‫is ready.
‫I need to link between these two parts, the data source and the adapter view.
‫So for that I'll create an adapter.
‫Initialize it here.
‫And I need to pass the sport list.
‫And when dealing with recyclerviews, you need to set a layout manager because we need to manage the
‫layout of its items.
‫So Recyclerview dot set layout manager to new linear layout manager and passing this as a Recyclerview
‫is the reference for the recyclerview instance that you with.
‫We've defined in the activity the set layout manager method.
‫This method is used to set the layout manager for the Recyclerview.
‫The layout manager is responsible for positioning and measuring the items within the recyclerview and
‫then you linear layout manager and passing this.
‫Here you are creating a new instance of the linear layout manager class, which is a built in layout
‫manager provided by Android.
‫The linear layout manager arranges items in a linear fashion either vertically or horizontally, and
‫this refers to the context to the current context, which is often an activity or a fragment, and in
‫this case, an activity.
‫It's used as a reference to the context in which the Recyclerview is being used.
‫Putting it all together, the line of code Recyclerview dot set layout manager is telling the Recyclerview
‫to use linear layout manager to manage the layout of its items.
‫This means that the items will be arranged linearly in either a vertically or horizontal orientation,
‫depending on how you configure the linear layout.
‫And by default it's a vertical orientation.
‫The last step is Recyclerview dot Set adapter to adapter, save the project, run the application and
‫here we go.
‫This is our application.
‫This is the other and these are our cards.
‫So you can see the rounded corner.
‫So congratulations, guys.
‫This is our amazing application.
‫I just need to edit this edit text or the text view and make it here.
‫Move it down and this is good.
‫Let me try.
‫And here we go.
‫This is our amazing application.
‫Volleyball, tennis, ping pong and football and basketball.