Hi!
I'm a newbie to Basic4Android but done some programming in VB6 so it's relatively easy to manage the 'basics'. I want to awoid codes like :
etc...
and instead programmaticly loop trough objects(wievs) and change properties.
I've read the tutorial mapping buttons and then create them with Activity.AddView.. .But can you map buttons created with designer ? I've not yet learned how to position wievs in program so designer is the best for me at the moment.
See code below :
Code compiles ok but don't change the checked property on the designer created Togglebuttons. Am I totally out in the blue or is there a solution to this?
Any help pointing me in right direction appreciated
Regards Håkan
I'm a newbie to Basic4Android but done some programming in VB6 so it's relatively easy to manage the 'basics'. I want to awoid codes like :
B4X:
btn_onoff1.Checked = False
btn_onoff2.Checked = False
btn_onoff3.Checked = False
btn_onoff4.Checked = False
and instead programmaticly loop trough objects(wievs) and change properties.
I've read the tutorial mapping buttons and then create them with Activity.AddView.. .But can you map buttons created with designer ? I've not yet learned how to position wievs in program so designer is the best for me at the moment.
See code below :
B4X:
Sub Globals
Dim btn_onoff1 As ToggleButton
Dim btn_onoff2 As ToggleButton
Dim btn_onoff3 As ToggleButton
Dim btn_onoff4 As ToggleButton
Dim btn_onoff5 As ToggleButton
Dim btn_onoff6 As ToggleButton
Dim btn_onoff10 As ToggleButton
Dim btn_onoff11 As ToggleButton
Dim btn_onoff12 As ToggleButton
Dim btn_onoff13 As ToggleButton
Dim btn_onoff14 As ToggleButton
Dim btn_onoff15 As ToggleButton
Dim btn_onoff16 As ToggleButton
Dim btn_onoff7 As ToggleButton
Dim btn_onoff8 As ToggleButton
Dim btn_onoff9 As ToggleButton
Dim Map1 As Map
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("TCP_main")
'######### map togglebuttons #############
Map1.Initialize
For i = 0 To 15
Dim Btn As ToggleButton
Btn.Initialize("ToggleButtons")
Map1.Put("btn_onoff" & i, Btn)
Btn.Tag = "btn_onoff" & (i+1)'starts with btn_onoff1
Next
Set_allON
End Sub
Sub Set_allON
Dim btn As ToggleButton
Dim x As Int
For x = 0 To 15
btn = Map1.GetValueAt(x)
btn.Checked = True
Next
End Sub
Code compiles ok but don't change the checked property on the designer created Togglebuttons. Am I totally out in the blue or is there a solution to this?
Any help pointing me in right direction appreciated
Regards Håkan