The ArrayAdapter serves as a link between the UI Component and the Data Source. It transforms data from the data sources into view items that may be shown in the UI Component. Data sources include Databases, Hash maps, and Arrays & UI Components, including Spinner, GridView, ListView, etc.
The ArrayAdapter changes the data source’s items into viewable ones. When we have an array, the ArrayAdapter transforms the array’s data into a UI Component.
The most commonly used adapter in Android is called ArrayAdapter. We can use ArrayAdapter if we have a list of single-type items in an array, whether we have a list of names, numbers, or cities. A single TextView appears in the layout of ArrayAdapter.
We can use CustomArrayAdapter in place of ArrayAdapter for layouts that require additional complexity.
public ArrayAdapter(Context context, int resource, int textViewResourceId, T[] objects)
context
: This value can’t be empty.
resources
: The resource ID for the layout file is used for creating views containing the layout.
textViewResourceld
: The textView’s ID in the layout resource must be filled.
objects
: These are the items that the ListView will display. This value can’t be empty.
If we want more customization in ArrayAdapter, we have to create CustomArrayAdapter and extend ArrayAdapter in that.
To provide further customization, we override all the functions of ArrayAdapter.
Free Resources