I've added two radio buttons to a panel in the designer.
When a radio is checked I save a small text file and then reload this when the app is restarted so I can set the last used radio button.
I can save and reload the file OK and I set the checked property to True but this doesn't fire the CheckedChange event as I expected. I have to add the RadioButton1_CheckedChange(True) line. Not sure if this is the way it's supposed to behave or am I doing something wrong ?
When a radio is checked I save a small text file and then reload this when the app is restarted so I can set the last used radio button.
I can save and reload the file OK and I set the checked property to True but this doesn't fire the CheckedChange event as I expected. I have to add the RadioButton1_CheckedChange(True) line. Not sure if this is the way it's supposed to behave or am I doing something wrong ?
B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.
Dim SaveFileName As String = "SaveFile.txt"
Dim SavedData As String
End Sub
Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Private Panel1 As Panel
Private RadioButton1 As RadioButton
Private RadioButton2 As RadioButton
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")
If File.Exists (File.DirDefaultExternal, SaveFileName) = True Then
SavedData = File.ReadString(File.DirDefaultExternal, SaveFileName)
If SavedData = "1.txt" Then
RadioButton1.Checked = True
'It only works if I add the line below
RadioButton1_CheckedChange(True)
Else
RadioButton2.Checked = True
'It only works if I add the line below
RadioButton2_CheckedChange(True)
End If
Else
SavedData = "1.txt"
RadioButton1.Checked = True
End If
End Sub
Sub Activity_Resume
End Sub
Sub Activity_Pause (UserClosed As Boolean)
End Sub
Sub RadioButton1_CheckedChange(Checked As Boolean)
File.WriteString(File.DirDefaultExternal, SaveFileName, "1.txt")
'Do other stuff...
End Sub
Sub RadioButton2_CheckedChange(Checked As Boolean)
File.WriteString(File.DirDefaultExternal, SaveFileName, "2.txt")
'Do other stuff...
End Sub