B4J Question B4XPages recommendations for multiple pages

Q: I want to make a B4XPages app that works with "all" systems (as many as reasonably possible). That app has/will have numerous pages, say 15. MainPage opens, you select an option that pops another up and hides MainPage. When the new page closes MainPage pops back up.
There seems to be many ways to do this. But is their a "preferred" way?". Initialize all pages when MainPage opens or initialize them as needed? Add page or. Add page and create. Select one page and close another? Does it even matter? I now have an app with 10 pages and it works in B4J as far as the pages go. But what is the best way to open, close, initialize, select, hide, open, whatever, particularly in B4A which I have barely played with.
Hope this Q makes some sense.


Staff member
Licensed User
You've probably seen this example: [B4X] B4XPages - Cross platform and simple framework for managing multiple pages

I recommend initializing and adding all pages when the program starts. This is a quick process as the UI isn't created.
In some cases it is actually useful to call B4XPages.AddAndCreate as it allows you to access UI elements of other pages without the need to check whether the pages were already created or not.
Upvote 0