

ArrayAdapter is more simple and commonly used Adapter in android.

It holds the data and send the data to adapter view then view can takes the data from the adapter view and shows the data on different views like listview, gridview, spinner etc. I have set proper comments beside the code snippets, so you can have an idea about what is going on here.In android, An adapter is a bridge between UI component and data source that helps us to fill data in UI component.

For this, I put the ListItem as a Linear Layout. You can change the textView or ImageView or EditText or anything of the ListItem. You can change the background of the items of list. After that, inside getView() method, here are some checkings which change the ListView dynamically. And the third parameter is the size of the listview. You may use List rather than ArrayList but I have used this for a purpose. The YourAdapter constructor receives the context of the Activity, the data as a ArrayList. The getView method returns a View, so be very careful about that. The YourAdapter class extends BaseAdapter and Override some methods of it. Here, I am going to show how a ListView of some Members can be generated. I faced a lot of situations where I had to implement dynamic ListView which changes according to user's input. Those who have basic knowledge of Android can easily understand this tip. The Adapter will inherit BaseAdapter class of Android, you can manage everything inside the Adapter class. Without an Adapter, you cannot implement a dynamic ListView. To customize a ListView, you need to customize Adapter of the ListView. There are some situations when Android Application Developers need to customize a listview.
