B4J Question button on tableview

ludogomez

Member
Licensed User
Longtime User
Hello,

I have a problem :
when I add a button on a tableview I don't have the good properties if I click on it.

B4X:
sub refresh
    For i = 0 To 10
        lbl1.Initialize("lbl1")
        btn1.Initialize("btn1")
        
        lbl1.Text = "lbl" & i
        btn1.Text = "bnt" & i
        btn1.Tag = "btn_tag" & i
        
        
                
        Dim row() As Object = Array(lbl1,btn1)
        TableView1.Items.Add(row)
        
    Next
end sub

Sub btn1_Click
   Dim b As Button
   b= Sender
   Log(b.Text)
   Log(b.Tag)
End Sub

Sub lbl1_MouseClicked (EventData As MouseEvent)
   Dim lbl As Label
   lbl = Sender
   Log(lbl.Text)
End Sub

on the log, if I click on every button I have always the last button.
It works with labels

Thanks
 

Daestrum

Expert
Licensed User
Longtime User
try putting the dim for the button inside the loop
eg
B4X:
    For i = 0 To 10
        lbl1.Initialize("lbl1")
        Dim btn1 as Button
        btn1.Initialize("btn1")
        ...
 
Upvote 0
Top