change state checbox's checked after remove item list view

时间:2015-07-28 15:35:14

标签: android android-listview

custom list view with custom checkbox,

Example : i have 4 data and all checkbox checked, i write command to remove item using OnCheckedListener, so when i click checbox the second item, the second item dissapear. the thrid item going up but the checkbox on the third item become checked = false as in the screen (when i debug it, the value still checked=true)

if i remove the third item then the 4th checkbox will be uncheck.

how to resolve this problem? thanks in advance, sorry for my english

1 个答案:

答案 0 :(得分:0)

In the onClick() or onCheckedChanged() method, whichever you are using, programmatically check which ones are checked, and toggle them.

Initialize as many CheckBox as you want, and then do this for all :

        if(chkbox1.isChecked()){
            chk1.toggle();
        }

        if(chkbox2.isChecked()){
            chk2.toggle();
        }
相关问题