‫We are going to create the second recycler view activity with the help of Cardview.
‫So we are going to display items in the card view.
‫In this video we are going to create the card view with the recycler view.
‫Now let's make a button here in the main activity that will reference us and go to the activity, the
‫card view activity.
‫So I will name this button.
‫I will rename it as card view button.
‫So this button will take us into the activity of the card view that display the cards.
‫Now I will make button card view.
‫Okay.
‫And I will make the same way.
‫Button.
‫Button two.
‫And this button two will be making an intent to the court of you that we are going to create in this
‫video.
‫Remember to rate us five stars on Udemy.
‫So you help us making new tutorials every day.
‫So we are uploading everyday tutorials.
‫And subscribe to our YouTube channel to get the latest tutorials.
‫Now I will make a new package here called Card View and Inside Card View.
‫I will make an empty activity called Card View Activity.
‫Okay.
‫In the same way and the same name as we have seen in the end.
‫Now I will import the r r package.
‫And.
‫Waiting for the gravel and everything is working fine now.
‫Closing the unnecessary and I will create a card view adapter.
‫So as we seen before, we need also a model class, a card view and the main activity of the card view
‫that we are going to implement the data.
‫So.
‫Also as at the level of layouts we need a layout for.
‫For the custom.
‫The custom a view I will call it name item underscore card.
‫So this is the the item template and the layout for the items of the cards.
‫I will make it there inside the card view linear layout.
‫So I have made the the main the main layout as a card view and inside the card view I will make a linear
‫layout containing four text views.
‫Okay.
‫So the first text view is called text name card.
‫I will make the annotation and the naming of the cards that refers to the card layout.
‫So we don't because our app will contain many declarations and many text views and many widgets.
‫I will name every package and every widget as the name of the package containing it.
‫So text view and text gravity card.
‫I have created three out of four.
‫I will later on make the four.
‫I missed it and inside the model class planet cards.
‫This will act as a model class.
‫I will create private string planet name too.
‫So planet name to refers to the cards, the cards active activity and card view package.
‫So number two, as I told you, this refers for card review activity and card view displaying.
‫The number one is referring to the normal recycler view that we have seen in the previous video.
‫I am making the getters and I have made the constructor.
‫Now let's move and make our adapter.
‫I will extend it.
‫First of all, as we see in the previous videos, recycler view dot adapter because we need to make
‫it custom.
‫We need to extend it from its upper upper class and I will make a card view holder.
‫A view holder.
‫Remember, guys, as I told you, I will.
‫I will make and remember you to make the card adapter class and the viewholder class.
‫Remember every custom adapter we need to make in recycler views, we need two classes.
‫The first one, the card adapter itself.
‫We need to initialize the constructor and make it and implement the methods and the second class.
‫We need to make a view holder that will extend the recycler view dot view holder.
‫So this is a very important note.
‫I will repeat it in order to to understand it and memorize.
‫In order to make a custom adapter, we need to extend first of all the recycler view adapter and pass
‫as generic as viewholder.
‫So what this means we need to configure the two card adapter, the two holders or the two classes.
‫First of all, the constructor of the adapter class itself and implementing the methods and the second
‫class would be the planet holder to which means it is a view holder, a custom view holder that extends
‫the recycler view the view holder.
‫It's very easy, guys.
‫Inside the view Holder We are going to initialize the widgets.
‫So I'm telling the Android studio, Hey, text name card is it is found in the item view and find the
‫view by by ID go and search for text name card.
‫And the same way for distance, same way for the gravity and the same way for diameter.
‫Okay.
‫So.
‫Ordered idea.
‫I text diameter card.
‫I maybe missed this.
‫I didn't make it.
‫Let me see.
‫Okay.
‫Maybe I have missed it.
‫Yes, I have missed it.
‫I need for text views.
‫I've made three.
‫I will copy it.
‫And because it's linear layout, it will be placed automatically under the gravity card.
‫Thanks to you.
‫Okay.
‫Till now, everything is working fine.
‫Now.
‫Let's make a method called set details.
‫And this details will take will take the planet cards, which is a modal class that we have made.
‫I named it cards in order to reference the to the card application or card activity.
‫Okay.
‫Because it is the same.
‫I will copy it from the previous video.
‫And nothing special.
‫I will name the rename the cards, the text views the card and.
‫These are the.
‫The variables.
‫Okay.
‫So.
‫Let's go to the card adapter class.
‫I prefer making the first one the viewholder, because to prevent the the the wrong implementation of
‫the methods, this is my way.
‫So I recommend it making the viewholder first, then making the a the adapter class.
‫Then.
‫Now.
‫I've made the context an array list.
‫Of type planet scored.
‫I will implement the methods.
‫These are the three methods on create viewholder and bind Viewholder and get item count.
‫These are the methods that we are going to implement.
‫Now.
‫Here we are.
‫We go by inflating and telling the Android studio, Hey, I'm going to use the item card that we have
‫designed before in order it as a template, as a layout for the for every item in this recycler view
‫and every card in this card view.
‫Okay.
‫So in the on binder view holder, I will pass planets card.
‫I will create an instance of planets card.
‫This is the model class that we have and I will pass it to the method that we have created.
‫Set details.
‫Okay, so planets, cards, we have an error here because it's it's a planet card.
‫You need to be planets.
‫Cards.
‫Okay.
‫Get planet name to gravity to add diameter to.
‫And here we go.
‫We have fixed it correctly.
‫Okay.
‫And the last step in the chords adapter is planets, dot size.
‫Everything is or should be working fine for our adapter class.
‫I will close it close unnecessary.
‫And I'm going to edit here the card view activity.
‫So in the inside the card view activity, which is the main activity, the activity of that will display
‫the cards.
‫We will make the recycler view, which is mandatory because we need to initialize the recycler view
‫and we need to make a card adapter instance which is called adapter and I will create an array list
‫of planets cards.
‫Okay, This is what we have done in previous minutes.
‫Now let's initialize the card view.
‫I will make the method here that will initialize the card views and put the data inside them using insert
‫data.
‫Method.
‫Now let's initialize it secular view.
‫Same way.
‫Find a view by ID and card.
‫Maybe I have missed making the recycler view.
‫Okay.
‫I will drag and drop recycler view here.
‫And zeros for the constraints.
‫And here we go.
‫I will add the ID here.
‫Recycler View cards Card.
‫Okay.
‫Recycler view card.
‫Now.
‫Set Layout Manager.
‫New layout Manager.
‫And passing the context as this this sorry, this planet array list equals new array list and adapter.
‫I will make an adapter of a new card adapter.
‫Remember, guys, if you have many adapters inside your application, make sure that you you specify
‫the correct adapter inside your your class.
‫Now.
‫Create data from four cards.
‫In this method, I will copy and paste the previous data that we have seen in the previous video.
‫Remember, guys, you can download the source code from our Udemy course and the resources for under
‫every under every video and every section.
‫I just making the cards.
‫Here.
‫And the realist skirts and cards and fixing it.
‫Okay.
‫Now I will make the correction for the planet array list.
‫It will be planets.
‫Remember guys to support us making new tutorials every day.
‫Just just rate us five stars on Udemy and subscribe to our YouTube channel.
‫Download our application master and master coding application from Play store.
‫Get all documentation of these.
‫Views and these videos and here we go.
‫We have our application.
‫Maybe I need some fixing of web content.
‫Yes, it would be web content.
‫And here we go, guys.
‫This is our Cod views.
‫Now let's make some some elevation and some padding, some coloration of cod view in order to show you
‫the corners, the elevation and the layout of the cod view.
‫Okay.
‫It's white and white.
‫It's not clear here.
‫I will make The background would be black.
‫Okay.
‫Background.
‫It would be black in order to see.
‫Okay, here we go.
‫We see the cards.
‫I will add margins.
‫The NDP.
‫It would it would be good.
‫And here we go.
‫These are the cards I will remove.
‫Make it four.
‫And here we go.
‫Thank you, guys.
‫I hope you stay safe from Corona.
‫And bye bye, guys.
‫And bye.