B4J Question [BANano] LoadLayoutArray question

Toky Olivier

Active Member
Licensed User
Longtime User
Hi,
It's the first time I used LoadLayoutArray and I cannot make it working.
I do like this:
B4X:
    Dim i As Int
    For i=0 To 10
        Dim elt As BANanoElement = SKContainer1.Element
        Dim index As Long = elt.LoadLayoutArray("myItem", False)
        Dim views As Map = BANano.GetAllViewsFromLayoutArray(Me, "myItem", index)
        Dim lbl As SKLabel = views.Get("sklabel1")
        lbl.Text = "Label " + index
        Dim btn As SKButton = views.Get("skbutton1")
        btn.Text = "Button " + index
    Next

But I always got an error:


The layout is like this:


The sample project:
 
Solution
1. SKContainer1 and SKLabel1 should have the AutoID off if you plan to use it in your code



2. Side note: a button inside a label does not render. I look into that but it looks like the Layout parser has a problem with that.



Alwaysbusy

alwaysbusy

Expert
Licensed User
Longtime User
About point 2. It is allowed, but by setting the SKLabel1 text later in code, you do overwrite the existing innerHTML (containing the button). This is because the SKLabel1 uses the .html() instead of .text(). I use .html() because you can add formatting to the text, which is done in html.

Alwaysbusy
 
Upvote 0

Toky Olivier

Active Member
Licensed User
Longtime User
Okay, thank you so much. I see what can I do.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…