There is a string variable on the page being created.
Both the Page Title and Page Id are String.
You didn't answer my question.
I don't know you don't understand my question or you are not interested to answer.
I think you are still very confuse with the concept of B4XPages.
Assuming your problem is the second one.
Get the value of page id of the B4XPage you want to show
This has nothing to do with:
So
When creating the page, it needs to be assigned the text "Page 2" from the string:
B4XPages.AddPage("Page 2", Page2)
Yes, you need to give ID to a page when you create a new page.
For example, you have a B4XPage with the name Page2.
You can create more than 1 page from the same Page2 class but you must give each of them different IDs.
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Public PageA As Page2
Public PageB As Page2
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
B4XPages.SetTitle(Me, "Main Title")
B4XPages.AddPage("AA", PageA.Initialize)
B4XPages.AddPage("BB", PageB.Initialize)
End Sub
Private Sub BtnShowPageA_Click
B4XPages.ShowPage("AA")
End Sub
Private Sub BtnShowPageB_Click
B4XPages.ShowPage("BB")
End Sub
However, if you want to show the title on Page2 base on it's id, you can write as follow:
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("Page2")
Dim PageId As String = B4XPages.GetPageId(Me).ToUpperCase
B4XPages.SetTitle(Me, "Page " & PageId) ' Title will show "Page AA" or "Page BB"
End Sub
Hope this is what you are looking for.