Wish [B4X] [XUI] xui.CreateLabel

Discussion in 'Bugs & wishlist' started by Alexander Stolte, Nov 22, 2018.

  1. Alexander Stolte

    Alexander Stolte Well-Known Member Licensed User

    This is the way to create a XUI Label:

    Code:
    Dim lbl_test as Label
    lbl_test.Initialize(
    "xlbl_test")
    Dim xlbl_test as B4xView = lbl_test
    with a xui.CreateLabel i can save 2 lines and a new label name.
    In a bigger project this would be very usefull.

    Greetings
     
  2. Star-Dust

    Star-Dust Expert Licensed User

    Try this: https://www.b4x.com/android/forum/threads/b4x-xui-sd-xuiview.96178/
     
    Alexander Stolte likes this.
  3. Erel

    Erel Administrator Staff Member Licensed User

    The reasons that XUI.CreatePanel was added are:
    1. Panels are very common controls.
    2. It requires a bit more code to create a cross platform panel as native panels are named Pane in B4J.

    If you find yourself adding many labels programmatically then create a sub for this:
    Code:
    Sub CreateLabel (Text As StringAs B4XView
     
    Dim l As Label
     l.Initialize(
    ""'assuming that events not needed
     l.Text = Text
     
    Return l
    End Sub
    Usage:
    Code:
    Dim lbl1 As B4XView = CreateLabel("Hello")
     
    jimmyF and Alexander Stolte 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