Android Question [SOLVED] [B4XPages] Remove page from Stack

makis_best

Well-Known Member
Licensed User
Longtime User
Hi

If I have load in my project 5 pages in my stack and i want to disappear the third page.
How I can do it?

Thank you.
 
1607282942129.png


Declare as public your pages in B4XMainPage - Class_Globals, so you can write something like:
B4X: Copy
B4XPages.ClosePage(B4XPages.MainPage.MyThirdPage)
 
Upvote 0
Declare as public your pages in B4XMainPage
Hi Luca: I think you can do either one of these methods below without declaring the page object as public. I am checking with you because you have become a powerhouse to be reckoned with in B4XPages.
Code: Copy
B4XPages.ClosePage(B4XPages.MainPage.MyThirdPage)
or:
Code: Copy
B4XPages.ClosePage(MyThirdPage)
Knowing you get by with little sleep, you do not need to rush to answer. This can wait till tomorrow.
 
Upvote 0
Of course you can close that page like that:
B4XPages.ClosePage(MyThirdPage)
but from within the B4XMainPage only. By declaring the pages public, as mentioned previously, you can manage them (even close them, as in this case) from within any other page that is not the B4XMainPage.

They, the B4XPages, are simply objects like any other; if in a module they are declared public, they will be accessible from anywhere in the project.
 
Last edited:
Upvote 0
Yes...
from B4XMainPage
not from another page.

Example: I have the B4XMainPage and 3 other: Pag1, Pag2, Pag3.
If I declare them Private in B4XMainPage, I cannot write, within Pag2:
B4X: Copy
B4XPages.ClosePage(B4XPages.MainPage.Pag1)
of course, because Pag1 is not public.

Note: writing simply "Dim" in Class_Globals it is implicitly Public, but I never write "Dim" there, only inside routines.
 
Last edited:
Upvote 0
As the pages instances are regular class instances, there are many ways to access the pages.

The two most common ways are:
- Declare them as public variables:
Code: Copy
B4XPages.ClosePage(B4XPages.MainPage.Pag1)
- Use B4XPages.GetPage:
Code: Copy
B4XPages.ClosePage(B4XPages.GetPage("Page 3 id"))
 
Upvote 0
Back
Top