‫Welcome back.
‫We learned about adapters and list view.
‫We succeeded in creating this application that uses simple list item one layout as a template for every
‫item in this list view.
‫If we open the simple list item one, we can see it.
‫It only contains this text view and this layout is built in layout in Android.
‫If I need to inflate my own and my custom layouts, what we need to do.
‫It's very simple.
‫I want from you to focus with me.
‫I'll create a new layout here and I'll name it as my custom layout.
‫Click okay and here go Split mode and you can see it.
‫It's an empty constraint layout.
‫No views here.
‫I'll start creating a text view Matchparent wrap content ID text view custom and the size would be 36
‫SP text would be item margin left £0.40, margin right £0.40 and click on this item and infer the constraints
‫and the change the height of this constraint layout to wrap content.
‫And here we go.
‫This is the layout of my new items.
‫I'll change the color of this text in order to distinguish it from the built in layouts.
‫I'll select black and I can change it from here I can change the green, yellow, red and whatever.
‫I'll change it to red.
‫Okay, this is our custom layout.
‫I want to display the items of the operating systems in a template using a text view with red color
‫and 36 SP as text size.
‫Now let's move to the main activity.
‫You are thinking of changing this layout to our layout, so let me change it for you.
‫Our layout dot my custom layout.
‫Run the application and here we go.
‫The application crashes.
‫Why?
‫Because we didn't initialize the items which is the text view.
‫And here Android is confused where I should inflate these items.
‫There are no places for these items.
‫To solve this problem, I need to create a class that acts as a custom adapter.
‫I don't need to use this adapter array adapter anymore.
‫I need to create my own and custom adapter in this application.
‫So create a new.
‫Kotlin class.
‫I'll name it as my custom adapter.
‫Click okay and this class will extend from base adapter here Base adapter.
‫And inside the constructor of this custom adapter class, I need to pass private val context, which
‫is a context object.
‫I need to pass it from the main activity and a private val items.
‫It's of type.
‫List of string.
‫The base adapter is an abstract class that provides a basic implementation of the adapter interface.
‫It's intended to be extended to create a custom adapter for populating data into views like List View,
‫Grid View, and other adapter view widgets.
‫In the next video, we're going to implement the methods that are inherited from this base adapter.