Android Question Button/Label Array click event problem

reddtechnologies

Member
Licensed User
Longtime User
Hi,
I have got the following simple code that compiles OK but click event doesn't work for both buttons and labels. I have got 4 labels and 4 bottons added in designer.

I have downloaded "taplabel_1" example and quite amazingly that works OK. I could not figure out the difference. I am using B4A version 6.80.


Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Button1, Button2, Button3, Button4 As Button
Dim Label1, Label2, Label3, Label4 As Label
Dim btn() As Button
Dim lbl() As Label
End Sub

Sub Activity_Create(FirstTime As Boolean)
'Do not forget to load the layout file created with the visual designer. For example:
Activity.LoadLayout("1")
btn = Array As Button(Button1,Button2,Button3,Button4)
lbl = Array As Label(Label1,Label2,Label3,Label4)
PopBtn
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub btn_click
Dim b As Button
b =Sender
b.Text = "Clicked"
End Sub

Sub lbl_click
Dim l As Label
l = Sender
l.Text = "Clicked"
End Sub

Sub PopBtn
Dim i As Int
For i = 0 To btn.Length-1
btn(i).Text = i
lbl(i).Text = i
Next
End Sub
 

ronell

Well-Known Member
Licensed User
Longtime User
did you set the event name for all the views in the designer

edit: see attached project, works fine
 

Attachments

  • button.zip
    7.6 KB · Views: 373
Last edited:
Upvote 0
Top