Android Question [B4XPage] B4XPages.AddPage vs. B4XPages.AddPageAndCreate

toby

Well-Known Member
Licensed User
Longtime User
Could someone give me an example, demonstrating that B4XPages.AddPageAndCreate(), not B4XPages.AddPage(), should be used.

TIA
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
AddPageAndCreate runs the B4XPage_Created, so "often" (always?) loads the layout.
True. Assuming that you are loading the layout in B4XPage_Created then it will always be loaded.

When you add a page with AddPage, B4XPage_Created will only run when the page is first shown (lazy loading).
Advantage: no performance impact when app starts.
Disadvantage: you cannot interact with the page views before the page is first shown.

AddPageAndCreate - adds the page and call B4XPage_Created
Advantage: no need to worry whether the page was already created or not. It will be ready immediately.
Disadvantage: if you are creating many pages when the app starts then it can slow down the app.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…