Android Question State manager save state togglebutton

angel

Member
Licensed User
Longtime User
Hello

How to save the state of one togglebutton in activity, other components not save

thanks
 
I wanted to use the module "StateManager" to save the state if the application closed, but do not know how to save the state of only one component and not the entire Activity
 
Upvote 0
Hello,

My little knowledge : for easiness I use Erel's PreferenceActivity library and store the state of the toggle button using a Boolean

Code: Copy
Sub ToggleButton1_CheckedChange(Checked As Boolean)
    If Checked Then
        Manager.SetBoolean("AC",True)
    Else
        Manager.SetBoolean("AC",False)
    End If
End Sub

You would recall the button's state in Activity_Resume

Code: Copy
    If Manager.GetBoolean("AC") Then
        ToggleButton1.Checked=True
    Else
        ToggleButton1.Checked=False
    End If
 
Upvote 0
Back
Top