Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("Page2")
kvs.Initialize(xui.DefaultFolder, "kvs.dat")
B4XSwitch1.Value = kvs.GetDefault("B4XSwitch1", True)
B4XSwitch2.Value = Not(B4XSwitch1.Value)
LoadCombo
B4XComboBox1.SelectedIndex = kvs.GetDefault("B4XComboBox1", B4XComboBox1.SelectedIndex)
End Sub
Sub B4XPage_Disappear
kvs.Put("B4XSwitch1", B4XSwitch1.Value)
kvs.Put("B4XComboBox1", B4XComboBox1.SelectedIndex)
End Sub
Sub B4XSwitch_ValueChanged (Value As Boolean)
LoadCombo
End Sub
Sub LoadCombo
#If B4a
Before = B4XComboBox1.SelectedItem
#Else If B4i
'1st option
If B4XComboBox1.IsInitialized Then
Before = B4XComboBox1.SelectedItem
Else
Before = ""
End If
'2nd option
' Try
' Before = B4XComboBox1.SelectedItem
' Catch
' Before = ""
' Log(LastException)
' End Try
#End If
Lista.Initialize
If B4XSwitch1.Value Then
Lista = Lista1
Else
Lista = Lista2
End If
B4XComboBox1.SetItems(Lista)
B4XComboBox1.SelectedIndex = Max(B4XComboBox1.IndexOf(Before), 0)
End Sub