The problem I am having is that the OnCheckedChangeListener
is being called if I scroll, and randomly switching the toggle state for other items in the list. I have worked a way around this for now(loading the state for the toggle button from a database field) but I do want an explanation as to why the OnCheckedChangeListener
for the togglebutton is active while scrolling, so I don't run into problems later.
Right now this is all I am doing with the code to test it.
btnToggle.setOnCheckedChangeListener(new OnCheckedChangeListener() {
@Override
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
Log.d("", "" + model.getId());
}
});