Android Question SD_XUIScrollView2D adding items to panel

james_sgp

Active Member
Licensed User
Longtime User
Hi all, I`m trying to add button array (in code) to a panel in a SD_XUIScrollView2D, if I don`t 'LoadLayout' the panel, I can't add the buttons. But the panel is scrollable, if I 'LoadLayout' i can then add the buttons, etc but it doesn't scroll.

Would appreciate pointers to what I`m missing here? I have attached my sample app.

Thanks,
James
 

Attachments

  • Map Test1.zip
    12.6 KB · Views: 93
Solution
Ok, great thanks...let me have a look. I see my problem I was trying to add the buttons to the panel, rather than the to scrollview.
Thank you StarDust :)

James

Star-Dust

Expert
Licensed User
Longtime User
If you want to scroll you have to change the size of the sliding panel inside the scrollView.
B4X:
XUIScrollView1.PanelHeight=NewHeight
XUIScrollView1.PanelWidth=NewWidth
You add the hall_layout panel inside the scrollView by loading it with LoadLayout, but you don't change the size of the scrollView's internal panel.
Also it is not necessary to load a panel with the LoadLayout, I did not understand what happens to you if you add buttons with AddView instead
 
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
Thanks, ur demo works as is. But i cant add the buttons to the panel (from code), cos it says panel is not initilised (if i dont't load the layout).

Or maybe i ask a simpler question, in the example how to i add buttons from code to the scrolling panel?
 
Last edited:
Upvote 0

Star-Dust

Expert
Licensed User
Longtime User
I removed the LoadLayout and inserted panels, no problem

1666339785235.png

B4X:
''xScrollView1.LoadLayout("layout2")
      
    For i= 1 To 10
        Dim P As B4XView = xui.CreatePanel("")
        P.Color=xui.Color_Red
   
        xScrollView1.AddView(P,i*35dip,10dip,30dip,30dip)
    Next
 

Attachments

  • Sample2.zip
    17.7 KB · Views: 73
Last edited:
Upvote 0

james_sgp

Active Member
Licensed User
Longtime User
Ok, great thanks...let me have a look. I see my problem I was trying to add the buttons to the panel, rather than the to scrollview.
Thank you StarDust :)

James
 
Last edited:
Upvote 0
Solution
Top