Looping Through Objects

mcgrandlej

New Member
Hi,
Hoping someone can help me. I have a number of imageviews name A1, A2...A10, B1, B2, ...B10 etc.

How can I use a loop to set an action when a user click it.

Ideally this would work, but it doesn't.
B4X:
Sub loopimages
   Dim currentIV As ImageView
   Dim currentLetter As String
   
   For i = 0 To 1
      Select Case i
      Case 0
         currentLetter = "A"
      Case 1
         currentLetter = "B"
      End Select
      For z = 1 To 10
         currentIV = currentLetter & z
         currentIV.Visible = False
      Next   
   Next
End Sub

Thanks!
 

Esop

Member
Licensed User
Longtime User
One way is to set each ImageView tag then set all ImageViews to the same Event.

B4X:
Sub ImageViewHandler_Click

   Dim imgView As ImageView
   imgView = Sender
   Dim currentLetter As String
      Select imgView.Tag
         Case "1"
         currentLetter = "A"
         Case "2"
         currentLetter = "B"
         Case "3"
         currentLetter = "B"
         'Do stuff
         imgView.Visible = False
         Case Else   
      End Select

End Sub
 
Upvote 0
Top