dimanche 20 août 2017

Android - How to save checkbox state (checked/unchecked) after changing activity

I have searched through StackOverflow, but have not found a proper answer yet.

I have created a ListView (iteration of a checkbox + itemview) and populated it through my customAdapter (which extends BaseAdapter).

I have a button which takes the values and print it on the screen via a Toast.

So far, so good.

Next step, I still have the button in the MainActivity, but the ListView is now in a child activity that I reach by clicking an image (ImageView placed in the MainActivity). I can still check the checkboxes, but I face two issues:

  1. I am still not able to pass the values to the MainActivity, where they will be printed on screen (or manipulated)
  2. As soon as I press the back button to go back to the MainActivity and I press again the image, every CheckBox that was checked is not checked anymore (they came back to default state)

I don't think that code is needed, as it comes from a standard implementation (ListView - customAdapter with ViewHolder implementation, ...), but in case just let me know.

Thanks a lot in advance!




Aucun commentaire:

Enregistrer un commentaire