android - Checkbox looses state on ListView scrolling -


I have a list view with one checkbox in each row to check for several items at a time when I list If I scroll down, my checkbox loses the state (this means I can not check all items at a time)

I have read many posts here and on the internet. Said that I was able to share my checked items in 'Areelist' Must Freiheit which I had tried before, but it does not work. At the moment, I store the state checked in the objects with all the other items on my list.

Here is the code for my adapter:

  Public category GalleryListAdapter extends Bid adapter {@ Override public view getView (last integer status, see conversion view, ViewGroup parent) {last Seeholder holder; If (convertView == empty) {convertView = inflater.inflate (R.layout.gallery_list_item, parent, wrong); Holder = New Viewholder (); // .. Other accessories holder Chkbox = (checkbox) ConvertviewfindbackBiID (RID Caxbox); ConvertView.setTag (holder); } And {holder = (seeholder) ConvertView.gettag (); } holder.chkbox.setChecked (documents.get (status) .isChecked ()); Holder.chkbox.setOnCheckedChangeListener (New On Checked Change Listener) {@CheckedChanged Override Public Zero (compounded button button view, bullion is checked) {holder.chkbox.setChecked (holder.chkbox.isChecked ()) true: false); Documents.get (status) SetChecked (holder.chkbox.isChecked ()) true: false);}}}}   

After scrolling down the list, my items are unchecked and Documents.get (checkedItemPosition)

Edit - Solution

Thanksgiving comments and replies I found a solution to my problem:

 < Code> if (convert = = empty) {holder.chkbox = (checkbox) convertviewfindvibidid (rd cboxbox); Convertview SetTag (R.id.chkbox, holder.chkbox);} holder.checkbox.settags (status); Holder.checksetset checked (get the document (status) .icc ()); Holder. Checkbox.Seton Checked Change Listener (New On-Checked Change Listener) {Public Zero (Compound Button Button View, B oolean is ischecked) on check-in {int getPosition = (Integer) button view.getTag (); holder .chkbox.setChecked (buttonView.isChecked ()? True: incorrect); documents.get (getPosition) .setChecked (buttonView.isChecked ()? True: incorrect);}}    

getView method set tag for checkbox holder.

  holder.chkbox.setTag (object); < / Code>  

and check-in to do this

  ** on the public on cyclical Turned (compact button button view, boolean check) {object obj = (object) button View.getTag (); Holder.chkbox.setChecked (obj.isChecked ()? True: incorrect); documents.get (status) .setChecked (Obj.isChecked ()? True: False); ** **   

This will relieve you of that problem;)

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -