views:

490

answers:

1

I'm using a ListView with CheckBox, but as most of you know, when you roll down the scroll, a checked CheckBox gets unchecked as you roll up back the scroll. So i've been reading and i found out that you can pass (using getView) the id of the CB to the position parameter of getView to save the CheckBox state!

But i can't use getView with SimpleCursorAdapter, can i? Because i'm using bindView!

Thanks

A: 

I managed to get the checkbox state restored after i scroll up/down using setViewBinder (saw it in another answer):

    mAdapter.setViewBinder(new SimpleCursorAdapter.ViewBinder() {
    public boolean setViewValue(View view, Cursor cursor, int columnIndex) {            
        if(columnIndex==4) {
            cb=(CheckBox)view;
            cb.setChecked(cursor.getInt(4)==0? false:true);
            return true;
        }
    return false;
    }
    });

But still something weird happens, the CheckBox is being recycled after 7 or 8 positions. If i check the first CheckBox and theres more than 10 positions/rows, the 8th is also checked, same happens when i check the last one, 8 positions up there will be a checked CheckBox.

Any thoughs? Ideias? Help!

Philipz