save the state of checkboxes in a list

我只是一个虾纸丫 提交于 2019-12-25 05:31:05

问题


I have a list with corresponding checkboxes, I would like to save the state of them so I can load the list of checked item when the app runs. How would I do this?

My onRetain looks like:

public Object onRetainNonConfigurationInstance() {
    return planets;
}

With planets being the entire list.

I have read up on SharedPreferences but I can't seem to get it working :(


回答1:


database::: Table name : state_checkBox

Fields position : int state : boolean

for code refer this links..

  1. Video

  2. example Code

you just have to update the state as "true" or "false" in the database but in getview all time you have to call a query to setChecked() the checkbox

& you hav to update the database on the checkedchangedlistner() of the checkbox...




回答2:


if you want to store in persistence you should use D.B. like this

if you want only for the session you should use bundle, here in example



来源:https://stackoverflow.com/questions/11949589/save-the-state-of-checkboxes-in-a-list

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!