StateManager with multiple panels

Geerts

New Member
Licensed User
Longtime User
Hello everybody,

I'm new at this all and i have a problem.
I'm using multiple panels and in the past when the activity was paused i lost all information.
After including StateManager in the code this was solved but it doens't seem to include which panel was visible. so in many occasion the wrong panel is visible after the pause.

you can find the code i'm using beneath. i hope there is an easy solution to this. Thnx to all !

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.

Dim btn1 As Button
Dim btn2 As Button
Dim EditText1 As EditText
Dim pnl1 As Panel
Dim pnl2 As Panel
Dim txtpnl1 As EditText
End Sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
'Activity.LoadLayout("Layout1")
Activity.LoadLayout("teststatemanager")

If StateManager.RestoreState(Activity, "Main", 60) = False Then
'set the default values
EditText1.Text = "Default text"
txtpnl1.Text = "Default text"
End If

End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)
If UserClosed Then
StateManager.ResetState("Main")
Else
StateManager.SaveState(Activity, "Main")
End If
StateManager.SaveSettings

End Sub

Sub btn2_Click
pnl1.Visible=False
pnl2.Visible=True

End Sub
Sub btn1_Click
pnl1.Visible=True
pnl2.Visible=False

End Sub
 
Top