I have a ListView with multiple choice entries where some are checked from the beginning using
setItemChecked(position, true);
I combine this with the filtering option
setTextFilterEnabled(true)
so it's easy to find a specific entry in the list.
The problem is that when I filter the list the entries switch position in the list view. Take for example three entries: 'A', 'B' and 'C' where 'C' is checked beforehand (i.e. the entry at position 3 in the list). When I type a 'C' on the keyboard, only the 'C' entry is displayed (as intended). Now 'C' is not checked anymore, since the entry has moved from the checked position 3 to the unchecked position 1 in the list.
This behavior leads to some not very welcome effects in the app. Is there a way to "move the selection with the filtering", i.e. bind the checked state to the entry and not to its initial position in the list? Or do I need to find a new approach?
Thanks,
Linus
Maintain a list of the selected items, and whenever the list is repopulated check if that id
(not position) exists in the list, and set as selected.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With