使用共享preference保存在一个ArrayList的5复选框值 [英] Using shared preference save 5 check box value in a arraylist
问题描述
我有在设置页面5复选框。当我点击保存按钮的变化将被保存在共享preferences,并且更改留在该页面本身。
I am having 5 check box in Setting Page. When i click save button the changes will be saved in shared preferences and also changes remained in that page itself.
上所做的更改要看,我必须表明在主页的相应按钮。
也就是说,如果我取消选中该复选框,按钮将不可见的主页。
Depends on changes made, i have to show the corresponding buttons in main page. ie, if i uncheck the check box, the button will not visible to the main page.
由于提前
推荐答案
了解如何的保存/共享preferences负荷preferences 的,它真的很容易。您可以保存/有关这些复选框状态负载布尔值。
Learn how to save/load preferences in sharedPreferences, it's really easy. You can save/load boolean values related to those checkboxes states.
在主界面,你可以在 onResume检查()
方法,这些布尔值previously共享preferences商店,然后显示/隐藏每个按钮使用例如:
On the main page, you can check in onResume()
method those boolean values previously stores in sharedPreferences and then show/hide each button using for example:
button3.setVisibility(checkbox3 ? View.VISIBLE : View.INVISIBLE);
编辑:
如果你的问题是如何存储在共享preferences一个ArrayList,那么答案是你不能。您只能保存(至少在原则上)简单变量,所以我建议你存储5布尔值,因为它是固定的数量。
If your question is how to store an ArrayList in sharedPreferences, then the answer is "you can't". You can only save (at least in principle) simple variables, so I recommend you to store 5 boolean values, since the number it's fixed.
这篇关于使用共享preference保存在一个ArrayList的5复选框值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!