‫Welcome back.
‫In this video, we'll discuss a very important concept in Android, which is the adapters.
‫An adapter basically connects the user interfaces and the data source.
‫According to the Android officials, an adapter object acts as a bridge between the adapter view and
‫the data.
‫For that view, Android adapters basically provide access to the data items.
‫The adapter is also responsible for making a view for each item in the data set.
‫Whenever we want to bind some data which we get from any data source, example ArrayList, HashMap,
‫SQL databases and etcetera with a UI component, which is the list view grid view and etcetera.
‫Then adapter comes into the picture.
‫So in this project I'll create a new list view and we'll discuss what are the list of views, and we'll
‫learn how to connect the list of view with the adapter and the data source.
‫So for that I'll create a new Android project, empty views activity, and I'll name it as adapters
‫app.
‫Click Enter.
‫And I'll start by defining a list of you.
‫A list view is a UI component that displays a scrollable list of items.
‫It's a fundamental part of the Android user interface toolkit and is commonly used to display lists
‫of text images or other view elements.
‫A list view is particularly useful when you have a collection of data that needs to be presented in
‫a vertical scrolling fashion.
‫I'll make as the width as matchparent and the height is Matchparent.
‫I'll give it an ID list view and I'll click on it in further constraints and it will fill the width
‫and height of the parent.
‫The items within the list of view are presented by individual views.
‫These can be simple text image views or even complex layouts containing multiple views.
‫Each item view corresponds to a single entry in the list.
‫Let's move to the main activity and make a reference for this list of view.
‫Start by list of view.
‫List of view and Alt+.
‫Enter to import the class of the list view from the Android widget Package list View equal Find the
‫view by ID or.id dot list view.
‫Remember the adapter acts as a bridge between the data source and the adapter view.
‫This is the adapter view.
‫The list of view is the adapter view.
‫The adapter View is a class in Android that provides a container to display a list of items or data
‫in a scrollable view.
‫It's part of the Android UI framework that acts as a placeholder for various types of adapter based
‫views like list, view, grid, view, Spinner and more.
‫In this case, it's a list of view and adapter.
‫View is responsible for managing the display of items on the screen and handling user interactions with
‫these items.
‫For example, list view is an adapter view that displays a vertical list of items that can be scrolled.
‫So in our case, the adapter view is a list of view.
‫This is the first step.
‫We initialize the adapter view.
‫We need a data source.
‫So the second step is the data source.
‫But what is the data source?
‫The data source refers to the collection of data that you want to display using an adapter.
‫It can be an array, a list, a cursor from a database, or any other data structure that holds the
‫information you want to show on the screen.
‫The data source is what the adapter takes as an input and the transforms into views for display within
‫the adapter view.
‫For example, if you're displaying a list of names in a list of view, the data source could be an array
‫or a list containing those names.
‫In this case, I'll create a new string array and make that data source as an end.
‫A string array countries.
‫So I have four countries in this string countries array.
‫So the first step is creating the adapter view that we need to display our items, the data source,
‫which refers to the collection of data that you want to display using an adapter into the adapter view.
‫And the third step is to create the adapter.
‫The adapter acts as a bridge between the data source and the adapter view.
‫So it's an adapter.
‫It's a bridge, it's a bridge between the adapter view and the data source.
‫It's responsible for binding the data to the views within the adapter view.
‫Let's create the adapter here.
‫I'll start with an array adapter.
‫It's of type string because I am passing here string data, I'll name it as adapter equal to new array
‫adapter and I need to pass the parameters here.
‫There are different types of adapters available in Android.
‫Depending on the type of adapter view you are using.
‫Some common adapters include array adapter which is used to bind an array or a list of items to a single
‫view resource.
‫I'll pass the parameters for the array adapter.
‫The first one is the context, the context or the place where you are.
‫The second parameter is the design for each item or each country name in the list.
‫I'll use a predefined android layout for the items which is called simple list.
‫Item number one.
‫Later on we will talk about customization of the list of views will replace it with our layout custom
‫layout.
‫The third parameter is the list of countries or the array of countries or the data source you are using.
‫I am using the countries array.
‫Once the adapter is prepared, you associated with the UI component by calling the set adapter method
‫on the UI component and in this case the UI component is a list view.
‫This establishes the connection between the data and the views that will be displayed on the screen
‫in Android.
‫The set adapter method is used to associate an adapter with a UI component that displays a collection
‫of data such as List, view, grid view or recycler view.
‫In our example is a list view.
‫The adapter is responsible for creating and managing the views that represent the individual items in
‫the collection.
‫And here we go.
‫This is our list view.
‫You can see these items.
‫There are four items countries in the data source that are populated in this list.
‫View using the adapter.