B4J Question [B4Pages]What is the best way to determine if a given page id exists?

William Lancee

Well-Known Member
Licensed User
Longtime User
I've tried a variety of ways, none elegant, and a Try block is the ugliest of all.
Note that a page can exist without being on the stack.
 

DonManfred

Expert
Licensed User
Longtime User
Maybe this?

B4X:
    Dim page As B4XPageInfo = B4XPages.GetManager.GetPage("PageIdToCheck")
    If page.IsInitialized Then
        
    End If
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
For now, I'll keep my own global B4XSet with page ids in B4XMainPage, and check with .Contains.
There is such a set in B4XPageManger, but it is not Public.
 
Upvote 0

William Lancee

Well-Known Member
Licensed User
Longtime User
In this project, the pages are created based on various decisions the user makes. Moreover, the initialization of the page is quite involved.
So at first I thought that I would not initialize the page instance until needed. Hence my question.

However, your answer made me take an hour and move the dynamic parts out of initialization and into create. It works very well.
Thank you.
 
Upvote 0
Top