Hallo,
I would like to create buttons from code and then create a click event for all.
I created an application to try but the code does not work
In this application I want the label to coincide with the number of the clicked button
Error code is:
java.lang.RuntimeException: Object should first be initialized (Button).
thanks and sorry for my bad English
I would like to create buttons from code and then create a click event for all.
I created an application to try but the code does not work
In this application I want the label to coincide with the number of the clicked button
B4X:
Sub Globals
Dim pulsanti(4) As Button
Dim Label1 As Label
End Sub
Sub Activity_Create(FirstTime As Boolean)
Activity.LoadLayout("Base")
For i = 0 To 3
pulsanti(i).Initialize(pulsanti_Click)
pulsanti(i).Tag =i
Activity.AddView(pulsanti(i),i*20%x,0,9%x,13%y)
pulsanti(i).Text=i
Next
End Sub
Sub pulsanti_Click
Dim send As Button
send =Sender
Label1.Text=send.Tag 'Error Point
End Sub
Error code is:
java.lang.RuntimeException: Object should first be initialized (Button).
thanks and sorry for my bad English