Help needed with checkboxes

Discussion in 'Android Hacks and Help' started by Shaun1203, Sep 21, 2012.

  1. Shaun1203
    Offline

    Shaun1203 New Member

    Joined:
    Sep 21, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I need some help with checkboxes. I want to be able to check a box and save the state of it so that when i close the app and then open it again, the box is still checked.

    Any help would be appreciated.
  2. MartinZ
    Offline

    MartinZ New Member

    Joined:
    Oct 21, 2012
    Messages:
    2
    Likes Received:
    0
    Trophy Points:
    0
    Use the isChecked() function of the checkbox.

    Find your checkbox by
    MyCheckbox = (CheckBox) findViewById(R.id.your_checkbox_id);

    You can save the state in the sharedpreferences or an other place.
    SharedPreferences | Android Developers