android - ListView checkbox issue after check -
my issue when check checkbox
turns checked duplicates checked state next listview
item isn't on visible list (e.g. when can see item on positions 0-5/6 on 1 screen element on position 7-8)...
this onclick method:
viewholder.messageselectbox.setonclicklistener(new view.onclicklistener() { @override public void onclick(view v) { if (viewholder.messageselectbox.ischecked()) { log.i("itemid", string.valueof(getitemid(position))); log.i("position", string.valueof(position)); mlistofitemstodelete.add(position); collections.sort(mlistofitemstodelete); collections.reverse(mlistofitemstodelete); } else { (int = 0; < mlistofitemstodelete.size(); i++) { int pos = mlistofitemstodelete.get(i); if (pos == position) { mlistofitemstodelete.remove(i); } } } } });
setonclicklistener
in getview()
in listview adapter...
getview()
method:
final viewholder viewholder; if (convertview == null) { layoutinflater inflater = (layoutinflater) context .getsystemservice(context.layout_inflater_service); convertview = inflater.inflate(r.layout.messages_list_view_single, parent, false); } viewholder = new viewholder(convertview); viewholder.messageselectbox = (checkbox) convertview.findviewbyid(r.id.messageselectbox);
so guys, have got idea wrong?
in getview()
have load checked state following before setonclicklistener
.
viewholder.messageselectbox.setchecked(mlistofitemstodelete.contains(position))
so checked state maintained in mlistofitemstodelete
, using state loaded checked state checkbox.
Comments
Post a Comment