Android Question Label Click Event not firing for new labels in array

jeffnooch

Member
Licensed User
Longtime User
i have this defined in Sub Globals

B4X:
   Dim lblCBtn() As Label
    Dim lblC15, lblC16, lblC17, lblC18, lblC19, lblC20, lblC25, lblCD, lblCT, lblC3 As Label

this array is also defined

B4X:
lblCBtn = Array As Label(lblC20, lblC19, lblC18, lblC17, lblC16, lblC15, lblCBull, lblCD, lblCT, lblC3)

i have a click event like this

B4X:
Sub lblC_click()
    Dim lC As Label
    lC=Sender
    Dim vCur As Int
    vCur = lC.Tag -1
    arrCurrent(vCur) = arrCurrent(vCur) + 1
    lblMrk(vCur).Text = arrCurrent(vCur)
End Sub

it works for lblC15-lblC25 which i have had working from before....i just added in lblCD, lblCT and lblC3...and the new 3 are NOT working...not sure what i missed any thoughts?

if i define them manually like this it does work as intended....just not sure why not working from the defined array and click event above?

B4X:
Sub lblCD_Click
    Dim vCur As Int
    vCur = lblCD.Tag -1
    arrCurrent(vCur) = arrCurrent(vCur) + 1
    lblMrk(vCur).Text = arrCurrent(vCur)
End Sub

any thoughts would be great...thanks
 
Last edited:

opus

Active Member
Licensed User
Longtime User
You didn't post where and how you did get the other lables onto your activity (from within the Designer or using .Initialize and .AddView) I would believe it was the later, in this case all the old labels have been created using something like:
B4X:
 Dim lblC20 As Label
 lblC20.Initialize("lblC")
That way the label would react on your lblC_click routine.
 
Upvote 0

jeffnooch

Member
Licensed User
Longtime User
this is what i have


B4X:
Dim lblC As Label
    lblC.Initialize("lblC")

but for some reason those last 3 still aren't working
 
Upvote 0

opus

Active Member
Licensed User
Longtime User
I would assume you have something similar for each of the working labels, like

B4X:
Dim lblC20 AsLabel
 lblC20.Initialize("lblC")
and you don't have that for the new labels.
 
Upvote 0

jeffnooch

Member
Licensed User
Longtime User
i'm not seeing that for all those labels...

the labels were added through the designer
and i'm using Script-General to size/resize/move them
 
Upvote 0

jeffnooch

Member
Licensed User
Longtime User
that was it Klaus...i forgot to change the event name (they were at their own default) in the designer for those labels...
thanks for your help....
 
Upvote 0
Top