Android Question Identifying programatically created panels

Fusseldieb

Active Member
Licensed User
Longtime User
Hi all,
I have a problem.
I am adding panels with labels inside. These panels are all inside a ScrollView and when the user reaches the final of the "list", it catches more items on the database and adds more panels...
Now I want to click on one of these labels to read the details of this item. But how can I "index" each panel, so that I can retrieve the right item?

The "Panel_Touch" sub doesn't help me much, because he has no ID or something to identify which panel it is.
It has only "Action", "X" and "Y".

Thanks in advance ;)
 

Xicu

Active Member
Licensed User
Longtime User
I use the tag panel property to index each panel that I create

B4X:
    Dim P As Panel
    P.Initialize("Preference")
    svPrincipal.Panel.AddView(P, 0, svHeight, svPrincipal.Panel.Width, ItemHeight)
    P.Tag = "Index" '(A single number or text)
.....

And at the event ...

B4X:
Sub Preference_Touch (Action As Int, X As Float, Y As Float) As Boolean
'Return True to consume the event
    'Save the selected value panel
    Dim SelectedPanel as panel
    SelectedPanel = Sender
    Select Case SelectedPanel.Tag
        Case "Index"
             Msgbox(SelectedPanel.Tag,"Panel Selected")
    End Select
End Sub
 
Upvote 0
Top