android - CheckBox unchecked in List<> not working -
would able me if checkbox !ischecked, why not delete item list?
this code:
checkbox.setoncheckedchangelistener(new compoundbutton.oncheckedchangelistener() { @override public void oncheckedchanged(compoundbutton buttonview, boolean ischecked) { string str = fajllista.get(position).getname(); if (ischecked){ kijeloltfajlok.add(new fajlok(str)); string x = ""; (fajlok : kijeloltfajlok){ x += a.getname() + "\n"; } toast.maketext(context, x, toast.length_short).show(); } else{ kijeloltfajlok.remove(str); string x = ""; (fajlok : kijeloltfajlok){ x += a.getname() + "\n"; } toast.maketext(context, x, toast.length_short).show(); } } });
supposing kijeloltfajlok object of type list, arraylist or similar (some object´s container), if want remove item of list using remove method should send parameter object want remove. looking @ code, sending parameter string object, 1 line:
string str = fajllista.get(position).getname(); but string never in array, no objects removed. iy want remove object, should send parameter fajlok object want remove.
Comments
Post a Comment