mercredi 24 décembre 2014

Iterate through custom ListView to save checked checkboxes and spinners

I have Activity A that runs Activity B with a button click.


Activity B has a list view with custom rows:


some rows have a title and checkboxes.


and some rows have a title and a spinner .


each row the user either checks the preferred checkboxes or chooses from a spinner.


so far so good. my problem is , when clicking back to Activity A, how do I save all the choices? and by save I don't mean just save his checked boxes but also get the values of his choices back to Activity A.


I don't want the choices to be saved even after I restart the app. only when the app is running .


So basically I need to : 1. get the user's choices and save their values (either from a spinner or from the checkbox) 2. save the ticked checkboxes the next time the user clicks to go to activity B


I thought about using onPause in Activity B , where I will get a reference to the listView, go through every row, see if there is a checkbox or a spinner there, and then somehow see what value is checked (if its checkboxes) and what value is selected(if its a spinner).


I don't know if it's the right approach or not, anyway I really need help here.





Aucun commentaire:

Enregistrer un commentaire