‫In this video, we are going to create a normal recycler view exactly like this app.
‫So this recycler view is one of the six recycler views that we are going to deal with.
‫The normal recycler view recycler view with the card view Single selection recycler view multiple selection
‫recycler view recycler view with swipe action and recycler view with multi view type.
‫So let's start building this amazing app.
‫In this video, we are going to create a normal recycler view.
‫First of all, I will create in the main activity six buttons, and that contains the normal recycler
‫view and recycler view with cart view.
‫Single Selection recycler View Multi selection recycler view recycler view with swipe action and recycler
‫view with multiple view type.
‫These are the six types of recycler view that we are going to work with.
‫So first of all, I will create an button that will make an intent to a to direct us into the normal
‫recycler view package and a direct.
‫That contains the activity for displaying our recycler view normal recycler view.
‫So.
‫In the main activity.
‫First of all, I create this button and later on in the videos I'm going to create the next five buttons.
‫But till now I will create the first button and set on click listener and I will make the intent for
‫passing or for going to the second activity that will display the normal recycler view.
‫I will create a new package.
‫I will name it normal recycler view.
‫And inside it I will create a new base, an empty activity called normal recycler view.
‫Important packages.
‫And here I will pass the intent.
‫Okay.
‫And starting the activity.
‫So.
‫Let me check.
‫Remove this.
‫And inside the main activity, a main activity for the normal recycler view.
‫I will create a recycler view here by dragging and drop.
‫And you need to import the package by, by or import the dependencies by clicking the download button
‫inside the the widgets panel.
‫Now initializing creating it, declaring the recycler view first and then initializing it by filing
‫view by Eddie and r.id dot normal recycler view back to the main activity.
‫I will correct this and put main activity dot test.
‫Now if we click on the button it will reference us into the normal recycler view activity that will
‫contain the recycler view.
‫I will create a recycler view, having a planet, a sorry, having an items of planets so it will display
‫the planets for me now.
‫Private planet adapter.
‫This is adapter class and I will create an array list of planet of type planet.
‫This is the modal class.
‫So I have created an adapter class and a planet class that acts as a modal class.
‫So if you want to learn more about Recyclerview deeply in this course, follow us correctly and open
‫your Android studio and start making your own projects.
‫In order to understand.
‫First of all, we start by normal Recyclerview layout manager.
‫And then array list creating it and adapter class that we are going to solve now and passing the context
‫as its parameter.
‫And the second parameter is an array list.
‫Planet array list.
‫We are going to solve this error in the planet adapter.
‫So don't worry guys now.
‫Normal recycler view.
‫Add the item decoration.
‫I will add a divider item a decoration.
‫It's very simple by making the linearlayoutmanager dot vertical.
‫So I will also make an.
‫A method called create list data.
‫I will make it later on, but till now I will make the planet.
‫So this method is for adding the data.
‫And the Recyclerview.
‫Look.
‫So now we have created a.
‫A class or sorry activity.
‫Normally recycler view, then we have created an adapter and then we have created the model class.
‫Now let's create some codes into planet.
‫Class.
‫This will act as a modal class, so I need to make three four for text views.
‫First one display the name of the planet and the other three text will display integers of distance
‫from the sun, the gravity and the diameter.
‫I created the constructor.
‫And I will create the getters.
‫Alt plus insert to add the constructor and the getters and setters.
‫Now let's move to the adapter.
‫Planet adapter.
‫It will extend recycler view.
‫Dot adapter class and as generic I will pass planet dot planet adapter dot planet Holder.
‫So remember, guys, it's very important to understand this.
‫Many people and many developers make mistakes at this level and didn't and have difficulties in understanding
‫the recycler view adapter.
‫If we have to make a custom adapter, we need to make an adapter and a holder.
‫So first of all, inside the inside the adapter, we need the two classes, the planet adapter, which
‫is, which is we have created now and the the holder.
‫So first of all, let's configure the planet adapter.
‫I have created a constant sorry, a context.
‫And then I will create an array adapter.
‫Array list.
‫Sorry.
‫And making the constructor.
‫So in this way we have solved the constructor.
‫Now I will implement the methods here.
‫For it in order to solve everything.
‫Okay.
‫I will implement the methods and three methods the oncreate, the get item count and viewholder.
‫Now I will create the method called Sorry.
‫I will create the class of planet Holder.
‫It will extend the recyclerview that viewholder.
‫This method is actually making like binding the views.
‫So all text views, all the names, all the references will go through this class.
‫I will create four text views.
‫And I will create now a custom layout.
‫And initialize the widgets here in the planet Holder constructor.
‫So go to the layout select layout New Resource file.
‫I will create a planet.
‫Lay out item.
‫I will drag and drop the item text view.
‫So remember, guys, you can get all source codes of our YouTube channel on this course on Udemy on
‫the description below.
‫So check our Udemy course and the resources inside every section and every lesson.
‫Okay.
‫This is the text of view.
‫And the size.
‫I will make it.
‫Bold and I will drag drop another text view.
‫Another text of you.
‫Maybe I will change this arrangement of this text of you later on in this video.
‫But till now it's.
‫It's good now.
‫I will name the ideas of this text abuse.
‫And changing the ID.
‫And here we go.
‫The diameter, gravity and the distance.
‫Okay.
‫Everything should work Fine.
‫Okay.
‫Adding some layout margins I removed.
‫Okay, so let's initialize.
‫These text views inside, as I told you The View.
‫So in order again as a recap in inside the adapter sorry, let's begin from the first in order to make
‫a recycler view custom recycler view, we need an activity adapter and a modal class.
‫Modal class is planet.
‫You put inside it all, your reference, all your variables that you are going to pass, and the recycler
‫view class that will initialize the recycler view and put the data and the adapter class that contains
‫the the adapter itself and a place view holder.
‫So the view Holder class here, it serves as planet holder and named as planet Holder for initializing
‫the custom layout that you are going to create.
‫So we need two layouts, the main activity layout that contains the main recycler view and the custom
‫item layout for our custom layouts of the recycler view.
‫And we need three Java classes one for recycler view activity, the second for adapter and the third
‫for the modal class.
‫It's very simple, guys, and it's very, very simple.
‫If you think it, think about it like this way.
‫So.
‫Here.
‫I'm going to pass the Or make the widgets.
‫The text widgets and I will format the distance from the sun and putting the percentage, the million
‫kilometers and getting the data from it here and pass it to the for the.
‫Percentage.
‫So I'm getting the variable planetquest.
‫I get distance from sun and I will put it inside the percentage D and the same way I'm going to get
‫the gravity and put it inside or replacing the percentage D.
‫Okay.
‫And I will put here.
‫The gravity and also the distance from sun.
‫And we need the.
‫Your local.us and diameter.
‫Percentage the.
‫And everything is working fine.
‫I will ensure that this.
‫Place or plant holder.
‫Here I have.
‫Planet after the planet Holder.
‫I will remove it.
‫I will remove.
‫Sorry.
‫The.
‫The view.
‫The planet adapter.
‫I should remove it.
‫And this oncreate view holder we need to initialize and use.
‫Make use of our view by using the layout inflator and I will pass the context, inflate auto layout
‫and I need to specify here the layout and inflate the custom layout that we have created before and
‫using parent and false attach to route.
‫So in this on Oncreate Viewholder, I'm telling the Android studio to view and make an inflate the layout
‫that I have created before and bind the viewholder here.
‫I'm going to set the planet adapter, the planet model class, and I will get the position of every
‫element that I'm going to create inside the normal recycler view activity.
‫Holder dot set details and passing an object of type planet.
‫Okay.
‫And here I will set the details.
‫And get it.
‫To the correct place.
‫Okay, so now everything is working fine.
‫Let's go back here and add some data inside our recycler view.
‫Planet.
‫New planet.
‫And I will.
‫You see guys state you is smart.
‫But for me, the planet name the distance from sun, gravity and the diameter.
‫These are correct.
‫Corrective data.
‫So Planet Array list add planet.
‫Let's run and see.
‫A normal.
‫Normal.
‫Okay.
‫Everything is working fine, but the layouts are.
‫Inside each other.
‫I will remove this.
‫Change it for here.
‫So you see, guys, I have a main activity that contains the button and this button will take you to
‫the correct recycler view that you need and the different recycler views and a recycler view in this
‫app will make its own work.
‫Now the Earth, everything is working fine.
‫Now I will add data.
‫Some margins here and margins.
‫Okay.
‫Now I will add some data here to save.
‫To save time.
‫Okay.
‫You can pause the video and add them.
‫These are the other planets and don't miss to add adapter dot net file dataset change.
‫Now let's run our application and see the final results.
‫Here we go.
‫This is our normal recycler view that we have created, so I hope you rate us five stars on Udemy.
‫So you help us making new tutorials and make this course the huge, the huge and the biggest course
‫in on the universe Rate US five stars.
‫Subscribe to our YouTube channel and download our app.
‫Thank you guys.
‫See you in next videos.
‫See you next.