Android Question Horizontal Scroll View - Accessing Individual Panels Inside

pauleffect

Member
Licensed User
Longtime User
Hello.

I am trying to start an activity when user clicks one of the panels held by an Horizontal Scroll View.
I read it's done with tags but I couldn't figure out how.

I have a for loop generating the panels and an array holding the said panels.

Thanks.
 

pauleffect

Member
Licensed User
Longtime User
No dice.

i-have-no-idea.png
 
Upvote 0

stevel05

Expert
Licensed User
Longtime User
You need to initialize the panels with an event name then create a sub {eventname}_Click, read the tag and start the activity.

Code from your previous question, if it's the same or related code.
B4X:
Dim Panels(667) As Panel
Sub CreatePanels
    For i = 0 to 666
        Dim cw as Panel
        cw.Initialize("Panels")
        cw.Tag = ActivityName 'See Note 1
        Panels(i) = cw
        Desiredview.Panel.AddView(cw,Left,Top,Width,Height)
    Next
End sub

Sub Panels_Click
   Dim P As Panel = Sender
   StartActivity(P.Tag)
End Sub

Note 1: You will need to decide how to assign the activity you want to start from each panel to the tag. Either within the loop using another array or list or separately:

B4X:
Panels(n).Tag = ActivityName
 
Upvote 0
Top