Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #1 I create a page: B4X: Copy Public Page2 As B4XPage2 Page2.Initialize B4XPages.AddPage("Page 2", Page2) B4XPages.ShowPageAndRemovePreviousPages("Page 2") The application uses: B4X: Copy #IncludeTitle: False How can I get the value "Page 2" when opening a page? I know that this value can be passed to a variable on Page 2, but I would like to get it from Root1. Last edited: Jul 14, 2025
I create a page: B4X: Copy Public Page2 As B4XPage2 Page2.Initialize B4XPages.AddPage("Page 2", Page2) B4XPages.ShowPageAndRemovePreviousPages("Page 2") The application uses: B4X: Copy #IncludeTitle: False How can I get the value "Page 2" when opening a page? I know that this value can be passed to a variable on Page 2, but I would like to get it from Root1.
aeric Expert Licensed User Longtime User Jul 14, 2025 #2 B4X: Copy Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("Page2Layout") B4XPages.SetTitle(Me, "Page2 Title") Dim PageId As String = B4XPages.GetPageId(Me) Log(PageId) ' page 2 End Sub It will show the Page Id in lowercase. Upvote 0
B4X: Copy Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("Page2Layout") B4XPages.SetTitle(Me, "Page2 Title") Dim PageId As String = B4XPages.GetPageId(Me) Log(PageId) ' page 2 End Sub It will show the Page Id in lowercase.
Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #3 aeric said: It will show the Page Id in lowercase. Click to expand... Thank you! It's a pity, but changing the title value doesn't work for me. It's strange, but in an application with B4X: Copy #IncludeTitle: True the title doesn't change. Upvote 0
aeric said: It will show the Page Id in lowercase. Click to expand... Thank you! It's a pity, but changing the title value doesn't work for me. It's strange, but in an application with B4X: Copy #IncludeTitle: True the title doesn't change.
aeric Expert Licensed User Longtime User Jul 14, 2025 #4 Sergey_New said: Thank you! It's a pity, but changing the title value doesn't work for me. It's strange, but in an application with B4X: Copy #IncludeTitle: True the title doesn't change. Click to expand... Don't confuse with Page Id and Page Title. To set Page Title, you write as follow: B4X: Copy B4XPages.SetTitle(Me, "Page2 Title") Upvote 0
Sergey_New said: Thank you! It's a pity, but changing the title value doesn't work for me. It's strange, but in an application with B4X: Copy #IncludeTitle: True the title doesn't change. Click to expand... Don't confuse with Page Id and Page Title. To set Page Title, you write as follow: B4X: Copy B4XPages.SetTitle(Me, "Page2 Title")
aeric Expert Licensed User Longtime User Jul 14, 2025 #5 I recommend to check my 2-pages template. [Project Template] [B4X] B4XPages (2-Pages) This is a minimal template with added only 1 new page. Why I created this template? The default B4XPages template has only 1 page (MainPage) The 3 pages example is little complex I always forget how I need to declare, initialize, add and show a page GitHub... www.b4x.com To use, download and drop this file into B4X Additional Libraries folder. Upvote 0
I recommend to check my 2-pages template. [Project Template] [B4X] B4XPages (2-Pages) This is a minimal template with added only 1 new page. Why I created this template? The default B4XPages template has only 1 page (MainPage) The 3 pages example is little complex I always forget how I need to declare, initialize, add and show a page GitHub... www.b4x.com To use, download and drop this file into B4X Additional Libraries folder.
Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #6 Sergey_New said: It's a pity, but changing the title value doesn't work for me. Click to expand... This is an incorrect Google translation. It should be like this: Sorry, but I don't need to change the case of the title. Upvote 0
Sergey_New said: It's a pity, but changing the title value doesn't work for me. Click to expand... This is an incorrect Google translation. It should be like this: Sorry, but I don't need to change the case of the title.
aeric Expert Licensed User Longtime User Jul 14, 2025 #7 Sergey_New said: incorrect Google translation Click to expand... So what exactly you want? 1. Do you want to change the title show on top of the page? 2. Get the value of page id of the B4XPage you want to show? Upvote 0
Sergey_New said: incorrect Google translation Click to expand... So what exactly you want? 1. Do you want to change the title show on top of the page? 2. Get the value of page id of the B4XPage you want to show?
Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #8 aeric said: So what exactly you want? Click to expand... There is a string variable on the page being created. When creating the page, it needs to be assigned the text "Page 2" from the string: B4X: Copy B4XPages.AddPage("Page 2", Page2) You need to get: B4X: Copy Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("Page2") ' Dim tmp As String=? End Sub Upvote 0
aeric said: So what exactly you want? Click to expand... There is a string variable on the page being created. When creating the page, it needs to be assigned the text "Page 2" from the string: B4X: Copy B4XPages.AddPage("Page 2", Page2) You need to get: B4X: Copy Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("Page2") ' Dim tmp As String=? End Sub
aeric Expert Licensed User Longtime User Jul 14, 2025 #9 Sergey_New said: There is a string variable on the page being created. Click to expand... 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. aeric said: Get the value of page id of the B4XPage you want to show Click to expand... This has nothing to do with: Sergey_New said: #IncludeTitle: False Click to expand... So Sergey_New said: When creating the page, it needs to be assigned the text "Page 2" from the string: B4X: Copy B4XPages.AddPage("Page 2", Page2) Click to expand... 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. Code: Copy Sub Class_Globals Private Root As B4XView Private xui As XUI Public PageA As Page2 Public PageB As Page2 End Sub Code: Copy 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 B4X: Copy 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: Code: Copy 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. Attachments Example.zip Example.zip 17 KB · Views: 237 Upvote 0
Sergey_New said: There is a string variable on the page being created. Click to expand... 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. aeric said: Get the value of page id of the B4XPage you want to show Click to expand... This has nothing to do with: Sergey_New said: #IncludeTitle: False Click to expand... So Sergey_New said: When creating the page, it needs to be assigned the text "Page 2" from the string: B4X: Copy B4XPages.AddPage("Page 2", Page2) Click to expand... 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. Code: Copy Sub Class_Globals Private Root As B4XView Private xui As XUI Public PageA As Page2 Public PageB As Page2 End Sub Code: Copy 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 B4X: Copy 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: Code: Copy 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.
Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #10 aeric said: This has nothing to do with: Click to expand... It seems that translation inaccuracies prevent us from understanding each other. I am attaching an example project, in which, as it seems to me, you can understand what I need. Comment out the line "Page2.lblHello.Text=str" and try to get the required text in the created page. I can't explain it better in an unfamiliar language. Pay attention to the line "#IncludeTitle: False" in the Main Activity. Attachments Test.zip Test.zip 4.8 KB · Views: 250 Upvote 0
aeric said: This has nothing to do with: Click to expand... It seems that translation inaccuracies prevent us from understanding each other. I am attaching an example project, in which, as it seems to me, you can understand what I need. Comment out the line "Page2.lblHello.Text=str" and try to get the required text in the created page. I can't explain it better in an unfamiliar language. Pay attention to the line "#IncludeTitle: False" in the Main Activity.
aeric Expert Licensed User Longtime User Jul 14, 2025 #11 B4X: Copy Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("page2") 'lblHello.Text = ? Dim PageId As String = B4XPages.GetPageId(Me) PageId = PageId.SubString2(0, 1).ToUpperCase & PageId.SubString(1) ' make first letter to uppercase lblHello.Text = PageId End Sub Attachments Test.zip Test.zip 14.9 KB · Views: 226 Upvote 0
B4X: Copy Private Sub B4XPage_Created (Root1 As B4XView) Root = Root1 Root.LoadLayout("page2") 'lblHello.Text = ? Dim PageId As String = B4XPages.GetPageId(Me) PageId = PageId.SubString2(0, 1).ToUpperCase & PageId.SubString(1) ' make first letter to uppercase lblHello.Text = PageId End Sub
William Lancee Well-Known Member Licensed User Longtime User Jul 14, 2025 #12 Sorry to interject, but I think there are some communication snags here. I looked at the code, and the problem I see is that the page is not yet created when the string is assigned. Change the .AddPage to B4XPages.AddPageAndCreate(str, Page2). Then the layout will be loaded and the string assignment will work. Upvote 0
Sorry to interject, but I think there are some communication snags here. I looked at the code, and the problem I see is that the page is not yet created when the string is assigned. Change the .AddPage to B4XPages.AddPageAndCreate(str, Page2). Then the layout will be loaded and the string assignment will work.
Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #13 aeric, thank you! Your example works. The difficulty of the example is that you will have to parse each word in the transmitted text, where there may be capital letters. It is easier to use Page2.lblHello.Text=str Upvote 0
aeric, thank you! Your example works. The difficulty of the example is that you will have to parse each word in the transmitted text, where there may be capital letters. It is easier to use Page2.lblHello.Text=str
Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #14 William Lancee said: Change the .AddPage to B4XPages.AddPageAndCreate(str, Page2). Click to expand... Both options work correctly for me. Which one is preferable to use? Upvote 0
William Lancee said: Change the .AddPage to B4XPages.AddPageAndCreate(str, Page2). Click to expand... Both options work correctly for me. Which one is preferable to use?
William Lancee Well-Known Member Licensed User Longtime User Jul 14, 2025 #15 As you said... It is easier to use Page2.lblHello.Text=str Click to expand... Upvote 0
aeric Expert Licensed User Longtime User Jul 14, 2025 #16 Sergey_New said: aeric, thank you! Your example works. The difficulty of the example is that you will have to parse each word in the transmitted text, where there may be capital letters. It is easier to use Page2.lblHello.Text=str Click to expand... Don't use page Id for passing values to another page. Just access the variable or view directly like you access lblHello. This is how B4XPages simplify things. Upvote 0
Sergey_New said: aeric, thank you! Your example works. The difficulty of the example is that you will have to parse each word in the transmitted text, where there may be capital letters. It is easier to use Page2.lblHello.Text=str Click to expand... Don't use page Id for passing values to another page. Just access the variable or view directly like you access lblHello. This is how B4XPages simplify things.
Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #17 William Lancee said: As you said... Click to expand... I meant AddPage or AddPageAndCreate Upvote 0
Sergey_New Well-Known Member Licensed User Longtime User Jul 14, 2025 #18 aeric said: Just call the variable or access the view directly... Click to expand... Please explain how to call a variable and how to access the view directly? Upvote 0
aeric said: Just call the variable or access the view directly... Click to expand... Please explain how to call a variable and how to access the view directly?
aeric Expert Licensed User Longtime User Jul 14, 2025 #19 Sergey_New said: Please explain how to call a variable and how to access the view directly? Click to expand... It is what you are doing now. In B4XPage2, you wrote: B4X: Copy Public lblHello As Label In B4XMainPage, you access it as follow: B4X: Copy Page2.lblHello.Text=str or if you want to access a variable in another page, you can write like this: In B4XPage2: B4X: Copy Public str As String In B4XMainPage: B4X: Copy Page2.str = "It can be any text" Upvote 0
Sergey_New said: Please explain how to call a variable and how to access the view directly? Click to expand... It is what you are doing now. In B4XPage2, you wrote: B4X: Copy Public lblHello As Label In B4XMainPage, you access it as follow: B4X: Copy Page2.lblHello.Text=str or if you want to access a variable in another page, you can write like this: In B4XPage2: B4X: Copy Public str As String In B4XMainPage: B4X: Copy Page2.str = "It can be any text"