I built with the Designer two Panel of 64 buttons each.
In the first panel, with code, each time you click on a button, it changes color and thus switches between green and black.
I retrieved the status values of each button from the first Panel in a Map (here "Mpbtn1").
Once the diagram is built in the first Panel I would like to update the buttons of the second Panel in a single time from the Map data using a loop (for fun), in the genre For i=0 to 63 ...next.
Initialization of Map
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Leds64Dessin")
Mpbtn1.Initialize
Mpbtn2.Initialize
For i=1 To 64
istring=i
Mpbtn1.Put(istring,1)
Mpbtn2.Put(istring,1)
Next
End sub
Update Panel1
Sub Button_Click
Dim cd1,cd2 As ColorDrawable
Dim Btn As Button
Btn = Sender
cd1.Initialize(Colors.ARGB(255,47,255,19), 89dip)
cd2.Initialize(Colors.Black,89dip)
istring=Btn.Tag
cpt=Mpbtn1.Get(istring)
If cpt=1 Then
Btn.Background=cd2
End If
If cpt=2 Then
Btn.Background=cd1
cpt=cpt-2
End If
cpt=cpt+1
Mpbtn1.Put(istring,cpt)
End Sub
In the first panel, with code, each time you click on a button, it changes color and thus switches between green and black.
I retrieved the status values of each button from the first Panel in a Map (here "Mpbtn1").
Once the diagram is built in the first Panel I would like to update the buttons of the second Panel in a single time from the Map data using a loop (for fun), in the genre For i=0 to 63 ...next.
Initialization of Map
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Leds64Dessin")
Mpbtn1.Initialize
Mpbtn2.Initialize
For i=1 To 64
istring=i
Mpbtn1.Put(istring,1)
Mpbtn2.Put(istring,1)
Next
End sub
Update Panel1
Sub Button_Click
Dim cd1,cd2 As ColorDrawable
Dim Btn As Button
Btn = Sender
cd1.Initialize(Colors.ARGB(255,47,255,19), 89dip)
cd2.Initialize(Colors.Black,89dip)
istring=Btn.Tag
cpt=Mpbtn1.Get(istring)
If cpt=1 Then
Btn.Background=cd2
End If
If cpt=2 Then
Btn.Background=cd1
cpt=cpt-2
End If
cpt=cpt+1
Mpbtn1.Put(istring,cpt)
End Sub