的CheckBox不是住在离开活动并返回后检查 [英] CheckBoxes not staying checked after leaving the activity and returning to it

查看:107
本文介绍了的CheckBox不是住在离开活动并返回后检查的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我组建了一个非常基本的Andr​​oid应用中,用户定义了使用的CheckBox一些preferences。我有一套因此,我想留下来选中或取消选中(取决于用户与他们如何互动),如果用户移动到previous活动,或为此事即使用户关闭应用程序,然后复选框重新打开它。我不知道如何去这样做,任何帮助吗?我会想象有一定的方法来使用保存的复选框的状态,但我不知道他们会或如何使用它们。

I am putting together a very basic Android app in which the user defines some preferences using CheckBoxes. I have a set of CheckBoxes which I therefore want to stay checked or unchecked (depending on how the user interacts with them) if the user moves to a previous activity, or for that matter even if the user closes the app and then reopens it. I'm not sure how to go about doing this, any help? I would imagine there are certain methods to use to save the state of the CheckBoxes, but I am not sure what they would be or how to use them.

推荐答案

您有几种选择(从易到最难)

You have several options (from easiest to the hardest)


  1. 使用共享preferences

  2. 将设置保存到文件系统作为.xml文件

  3. 将设置保存到本地SQLite数据库

这篇关于的CheckBox不是住在离开活动并返回后检查的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆