There is a ListView . It contains Animals objects with the following fields: isAnimal , isBird , isFish etc. Values ​​can be 0 or 1 (true / false). It is necessary that the list be filtered in real time depending on the selected checkbox combination.

I used to write a filter through the search string (I added getFilter() to the adapter), but apparently if I need to filter the ListView through checkboxes, this option will not work.

Tell me, please, which way to dig?

  • And what prevents to use the Filterable interface in principle? - pavlofff

1 answer 1

Generate a new list of animal model objects based on checkbox marks and pass to the adapter, then notifyDataSetChanged() , as the simplest option.

If the data is stored in the database, then select by the selected and also transfer it to the adapter, then update the list via notifyDataSetChanged()

  • Somehow I thought so, but apparently it meant: to save the full list of objects (in case all the checkboxes are canceled), scan the list of objects and delete from the list that did not match the marks, do notifyDataSetChanged ()? In the case of cancellation of all checkboxes, return the full list and again notifyDataSetChanged ()? - Chekist
  • It depends on where your model objects are stored when you exit the application. It is better not to modify the full list, but to form a new one - pavlofff