0

I am seeing a problem that happens sometimes, depending on how the user scrolls the ListView.

Basically my ListView item contains of some checkboxes and a SwitchCompat which all have their OnCheckedChangeListener set inside the getView of the adapter.

The problem is that, sometimes during regular scroll, the OnCheckedChangeListener fires and the values change, when the list should only scroll.

How should I handle this? Is there a simple way to disable any item's clicks while the list is scrolling?

Alin
  • 14,809
  • 40
  • 129
  • 218
  • 4
    I think maybe this is problem about row reuse not `OnCheckedChangeListener` fires when scroll – Linh Oct 03 '16 at 08:25

1 Answers1

1

When you scroll, getView gets executed which fires your OnCheckedChangeListener method.

vhold.checkbox.setOnCheckedChangeListener(null);
if(chonditionforchecking) {
    vhold.checkbox.setChecked(true);
} else { 
    vhold.checkbox.setChecked(false);
}

There are more solutions on this link

Community
  • 1
  • 1
Techidiot
  • 1,921
  • 1
  • 15
  • 28