0

Is it possible to have some listview rows have a checkbox, or a switch and others to nothing just a title and remain clickable.

I am trying to a do a listview that has a few different settings.

  1. First - Checkbox
  2. second - Switch
  3. Third - Just list.

I know I could do them as separate buttons I would like to have them filled from the same array if possible?

Nakatomi
  • 104
  • 2
  • 13

1 Answers1

1

YES Definately Its possible...

1. Create a custom layout for ListView or RecyclerView row item with CheckBox, Switch, TextView or other views as per your requirement.

2. Create a custom adapter extending from ArrayAdapter, BaseAdapter or RecyclerView.Adapter to populate list data to your custom layout.

3. In getView() or onBindViewHolder() method, set data to your views and add required OnClick or OnCheckedChange listener to your Views.

Here are some tutorial link:

  1. Android Custom ListView with CheckBox
  2. Android RecyclerView with CheckBox
  3. ListView with CheckBox using custom Adapter class
  4. Android ListView with Checkboxes
  5. Android Custom ListView with Image and Text

Hope this will help~

Ferdous Ahamed
  • 21,438
  • 5
  • 52
  • 61