‫Welcome back.
‫We created this custom item layout.
‫Now let's move to the main activity.
‫Remove this text view and replace it with list view.
‫Match.
‫Parent.
‫Match.
‫Parent ID list view and click on this list view and infer the constraints.
‫Or you can add the constraint attributes manually and link them to the parent.
‫Now I want from you to focus with me because I'm going to introduce a new concept here.
‫Inside this package, I'll create a new Kotlin class and I'll select a data class.
‫And here I'll name it as planet.
‫Click okay.
‫And here we go.
‫This is our data class in this project.
‫But what is data class?
‫When working with a list view in Kotlin, using a data class can be beneficial to represent the data
‫you want to display in a clean and efficient way.
‫A data class is a special class that is designed to primarily hold data.
‫It's it's concise to automatically generates useful methods like toString, equals hashCode, and copy
‫methods based on the properties declared in the primary constructor.
‫If we go back to the custom layout, we have one image view and two text views.
‫So this data class acts as a template for every planet that would be displayed in the list view.
‫For that, I need to declare three variables in the constructor of the planet one of type int and two
‫of type strings.
‫Strings referred for these text views, and the int is referred for the image view.
‫In Android, image view is often referred to using an integer resource identifier.
‫This is because these adapters in the list view or recycler view use the concept of a viewing.
‫Recycling for better performance and using resource identifiers helps identifying and efficiently reuse
‫the views.
‫And to reuse this image view, I need to pass as an identifier an int.
‫So val title.
‫It's of type string val moon count.
‫It's of type string and val image planet.
‫It's of type int.
‫This is our data class called planet.