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:
2022-04-07 09_19_59-BANano Skeleton.png


The layout is like this:
2022-04-07 09_21_36-myItem - (TestBananoPWA) Visual Designer.png


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

1649308589183.png


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.

1649308739264.png


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
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
Okay, thank you so much. I see what can I do.
 
Upvote 0
Top