I have 8 buttons on a panel and I want to set the tag and text value at runtime based on values in contacts. I am getting the contact data OK but when I try and update the buttons with it only the first button is updated rather than each button in turn being updated. I thought the value v would be set to each button in turn but it does not appear to be doing so. Code below.
counter = 0 'contact counter
For Each v As View In pnlButtons.GetAllViewsRecursive
Private c As CustomContact
c.Initialize
c = contactsList.Get(counter)
If c.DisplayName = "" Or c.phoneNumber = "" Then
Do While c.DisplayName = "" Or c.phoneNumber = ""
'stay on same button and go to next contact
counter = counter + 1
c = contactsList.Get(counter)
Loop
Else
counter = counter + 1
End If
If counter >= numButtons Then
Exit
Else
updateButton(v, c)
End If
Next
End If
End Sub
Private Sub updateButton(b As B4XView, c As CustomContact)
b.Text = c.DisplayName
b.Tag = c.phoneNumber
b.Enabled = True
b.Visible = True
counter = 0 'contact counter
For Each v As View In pnlButtons.GetAllViewsRecursive
Private c As CustomContact
c.Initialize
c = contactsList.Get(counter)
If c.DisplayName = "" Or c.phoneNumber = "" Then
Do While c.DisplayName = "" Or c.phoneNumber = ""
'stay on same button and go to next contact
counter = counter + 1
c = contactsList.Get(counter)
Loop
Else
counter = counter + 1
End If
If counter >= numButtons Then
Exit
Else
updateButton(v, c)
End If
Next
End If
End Sub
Private Sub updateButton(b As B4XView, c As CustomContact)
b.Text = c.DisplayName
b.Tag = c.phoneNumber
b.Enabled = True
b.Visible = True