B4J Question Adding a Label to a ScrollPane

Discussion in 'B4J Questions' started by wdegler, Sep 4, 2014.

  1. wdegler

    wdegler Active Member Licensed User

    This seems like a very elementary question but I have seen no explanation or example of it:

    How can I add a Label to a ScrollPane?
    Unlike "Pane", ScrollPane has no "AddNode". None of the available parameters for ScrollPane seem to apply to this. So far, I have only done this using SceneBuilder but now I need to do it programmatically. What is the syntax?

    Any help, such as an example and direction to where such information can be found will be much appreciated.
     
  2. Erel

    Erel Administrator Staff Member Licensed User

    You should add the nodes to the ScrollView inner node:
    Code:
    Dim p As Pane = ScrollView.InnerNode
    p.AddNode(...)
     
  3. wdegler

    wdegler Active Member Licensed User

    Thank you, Erel! This is exactly what I needed to know. I assume that "ScrollView" is meant to be of type "ScrollPane. I note that ScrollView is a type in B4A.
     
  4. Erel

    Erel Administrator Staff Member Licensed User

    You are correct.
     
  5. zyblux

    zyblux Member Licensed User

    Hi,
    Is there a way to get the scroll pane automatically show the scroller as needed when the content grows by adding controls dymanically @ runtime?

    The horiz-scroller only seems to appear in the designer if the content doesn't fit into the scroll pane.

    Heres some sample code that shows what I'm trying to do:

    Dim p As Pane

    p.Initialize("")
    p = scrollpane.InnerNode
    bread.Initialize("breadA")
    p.AddNode(bread, 60, 5, -1, -1)
    bread.SetItems(Array("Crumb 1", "Crumb 2", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3", "Crumb 3")


    It seems the anchorpane (innernode) does not increase in width when large breadcrumb control is added so no horizontal scroller appears :( This means you can't see half the breadcrumbs (unless I maximize the form).

    Note: this is not bread crumb specific , the same thing happens when adding say 30 buttons in a row, next to each other.


    Thanks
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    Please start a new thread for this question.
     
  7. sorex

    sorex Expert Licensed User


    when I try this it always gives an error that the innernode is not initialized, I can't initialize it either by code.

    does this only work with code generated scroll panes?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    The simplest way to add content to a ScrollView is by loading a layout file with: ScrollView.LoadLayout.

    If you want to create the layout programatically then you need to first create a Pane and set it to ScrollView.InnerNode.
     
  9. sorex

    sorex Expert Licensed User

    this works
    Code:
    sv.Initialize("")
    p.Initialize(
    "")
    p=sv.InnerNode
    but when I use the designer created one it always fails.

    Code:
    p.Initialize("")
    p=scrollMap.InnerNode
    I just want to add an image to the scrollview
     
  10. sorex

    sorex Expert Licensed User

    Ooooooooooh! you need to set it first

    I thought it would set one during the creating and that you had to link it to your own pane.

    It works fine now, thanks for the hint!
     
    Last edited: Aug 4, 2015
  11. rbirago

    rbirago Member Licensed User

    I have followed these posts, but in practice I cannot add a Pane to a ScrollPane. Can you please attach a working example (perhaps there is some trick that I've not understood).
    thanks
     
  12. Erel

    Erel Administrator Staff Member Licensed User

    This post is old.
    The correct way to set the content of ScrollPane is with ScrollPane.LoadLayout.
     
  13. rwblinn

    rwblinn Well-Known Member Licensed User

    Hi,

    pls find attached one way of using the ScrollPane.
    For this example, it is filled with Labels via Code (with little gimmick when selecting a label).

    Note, that there might be other solutions as well to work with the Scrollpane.
     

    Attached Files:

    HowardTheDuck, juvanum and GGSoft like this.
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice