I have a custom list view with selectable items. And I am trying to select all items automatically present above the one I selected. For Ex: Suppose there is 10 items in the list view and I selected 5th then it should select all the items available above 5th. i.e(1,2,3,4) and when I deselect 3rd item 1,2,3 items should deselected automatically

1

There are 1 best solutions below

0
On

// Assume that you have a list of items called 'items' and the index of the //In This method you parse the index which one you tap.

ontap(int index){

   for (int i = 0; i < index; i++) {
        items[i].isSelected = true;
        }
   for (int i = (index + 1); i < item.length; i++) {
        items[i].isSelected = false;
        }
}