B4J Question [ABMaterial] how to change and Refresh

Gianni M

Well-Known Member
Licensed User
Longtime User
i write
B4X:
Public Sub ConnectPage()
'
Dim btn1 As ABMButton
btn1.InitializeRaised(page, "btn1", "", "", "BUTTON", "bluegrey")
page.Cell(2 , 2).AddComponent(btn1)
'
dim myName as String = "Gianni"
page.Cell(2 , 3).AddComponent(ABMShared.BuildParagraph(page,"id2" , myName))
'
page.Refresh ' IMPORTANT!
page.FinishedLoading 'IMPORTANT
and
B4X:
Sub btn1_Clicked(Target As String)
'how to change and refresh component id2 ???
'myName="Gianni Maione"
End Sub
 

Mashiane

Expert
Licensed User
Longtime User
Looking at your example, the ABMShared.BuildParagraph call is how the ABMLabel was added to R2C3 on your page.

This could be looking like this.

B4X:
public Sub BuildParagraph(page As ABMPage, id As String, Text As String) As ABMLabel
    Dim lbl As ABMLabel
    lbl.Initialize(page, id, Text , ABM.SIZE_PARAGRAPH, False, "justify")
    Return lbl
End Sub

This method creates an ABMLabel component in memory and then thats gets added to R2C3. In this particular instance you can do two things, 1 declare an ABMLabel in Class_Globals and reference it or simply in btn_clicked add

B4X:
Dim lbl as ABMLabel = page.Components("id2")
lbl.Text = "Gianni Maione"

What the AddComponent did was to call the BuildParagraph method, which created an ABMLabel component and then added it to the page. All components that get added to a page will sit in a "Components" object that you can then get using the ID of the component you created, thus page.Components(xxx) call.

All the best...
 
Upvote 0

Gianni M

Well-Known Member
Licensed User
Longtime User
perfect!

another question:
how to chain / call / link another page ?
B4X:
Sub btn1_Clicked(Target As String)
'here i want call "../mypage/mypage.html"
End Sub
mypage exists , but not is in "page.NavigationBar.AddSideBarItem" on left menu
 
Upvote 0
Top