Custom ListView is very useful for customizing view and make app interface more attractive. In this post i explain how to make custom adapter and how its work.

Adapter: Adapter is used to set view inside your ListView or Spinner etc.

1. Create new project in android studio.

2. Open activity_main.xml inside your res/layout folder and add ListView inside it.

3.  Now create new view you want to inflate in your ListView. In this i have one ImageView for image two TextView one for Name and other for sub heading and also one CheckBox.

4. Now before start creating custom adapter for your ListView create some getters and setters. I alway use getters and setters whenever i have to do this kind of thing. For more follow this. Why use getters and setters?

5.  Now create your custom adapter

In this i pass my ArrayList and context through constructor. I extend  BaseAdapter in for my custom Adapter . In this user set all data in list we get and put it in view now when user click on check box {Check/Uncheck} we setCheckBox value to true/false and

The definition of notifyDataSetChanged in the Android‘s documentation is as folow

Notifies the attached observers that the underlying data has been changed and any View reflecting the data set should refresh itself.

This is really very important thing to do when we deal with check box in ListView due to the nature of ListView. To know more about ListView please follow this link .

6. Now last step open your MainActivity.java and paste bellow code.

That it. Now your Custom Listview is ready to use. You also create a custom adapter for your spinner like this.

🙂