Android Question Sender object loosing value

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi,

I have panels in scroll view pnlUsers. Defined in global.
When user clicks panel it fires pnlUsers_Click event.
I have used it dozens of times but this time sender object is not having Tag value i assigned to it while adding panels to scroll view panel.
Any reasons.

Adding panel
B4X:
                    pnl.Initialize("pnl")
                    pnl.LoadLayout("Panel_Users")
                    lblMemberName.Text=m.Get("MemberName")
                    lblMemberID.Tag=m.Get("MemberID")
                    pnl.Tag=m.Get("MemberID")
                     If n=0 Then
                        svUsers.Panel.AddView(pnl,0,0,100%x,9%y)
                        svUsers.PANEL.Height=pnl.Height
                    Else
                        svUsers.Panel.AddView(pnl,0,svUsers.Panel.Height+1%y,100%x,9%y)
                        svUsers.PANEL.Height=svUsers.PANEL.Height+1%y+9%y
                    End If

Firing event
B4X:
Sub pnlUsers_Click
Dim pnlx As Panel
pnlx=Sender   
SelectedUserdID=pnlx.tag
StartActivity("frmViewUserProfile")
End Sub

Pls give some clue.

Thanks
Juzer
 
Last edited:

JordiCP

Expert
Licensed User
Longtime User
According to the code above, you are watching pnlUsers_Click event, but you initialized your panel with

pnl.Initialize("pnl")

, so the event name should be pnl_Click
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Hi JordiCP,
No pnl is a local variable, pnlUsers i defined as global variable corresponding to the view i have taken in designer.
The event pnlUsers_Click is firing properly as it should.Sender is giving value "txt" which is incorrect.
Juzer
 
Upvote 0

klaus

Expert
Licensed User
Longtime User
No pnl is a local variable, pnlUsers i defined as global variable corresponding to the view i have taken in designer.
But the Tag belongs to pnl and not to pnlUsers.
Try to set pnlUsers.Tag = m.Get("MemberID")
I'm not sure, but I think, in thar case, that you need to declare pnlUsers also local and not as global, otherwise pnlUsers will link to the last instance.

Or maybe try pnlx.Parent.Tag

Or, you could also use, as suggested by JordiCP, pnl.Initialize("pnl") and pnl_Click and then you can get the different views on pnl with pnlx.GetView(Index).
 
Upvote 0

Juzer Hussain

Active Member
Licensed User
Longtime User
Sorry JordiCP, Klaus that was the problem. Since event was firing properly i was ignoring it. I changed panel name and its ok now.
Thanks
 
Upvote 0
Top