Android Question [B4XPages] Wait for page appearing

Alessandro71

Well-Known Member
Licensed User
Longtime User
Consider the following code fragment

B4X:
Dim dwp As DataWizardPage = B4XPages.GetPage("DataWizardPage")
B4XPages.ShowPage("DataWizardPage")
B4XPages.ClosePage(Me)
dwp.BeginConnection

I'm in a page other than B4XMainPage
I need to show a page (which gets created at the first run), close the current one and call a sub inside the new page
The code crashes because ShowPage and ClosePage appears to be async and BeginConnection starts when the page is still being created and some views used by BeginConnection are not yet available
What's the correct way to wait for page completion before continuing?
 

toby

Well-Known Member
Licensed User
Longtime User
Consider the following code fragment

B4X:
Dim dwp As DataWizardPage = B4XPages.GetPage("DataWizardPage")
B4XPages.ShowPage("DataWizardPage")
B4XPages.ClosePage(Me)
dwp.BeginConnection

I'm in a page other than B4XMainPage
I need to show a page (which gets created at the first run), close the current one and call a sub inside the new page
The code crashes because ShowPage and ClosePage appears to be async and BeginConnection starts when the page is still being created and some views used by BeginConnection are not yet available
What's the correct way to wait for page completion before continuing?
Call BeginConnection in dwp page:
Sub B4xpage_create
'your initialization code

 BeginConnection
End sub
 
Upvote 0

Alessandro71

Well-Known Member
Licensed User
Longtime User
Call BeginConnection in dwp page:
Sub B4xpage_create
'your initialization code

 BeginConnection
End sub
simple but wrong :)
not every time the page will open, the BeginConnection sub should run...
rephrasing the question: how to wait for a page to be fully created and available before calling a sub that belong to it?
B4XPages.AddPageAndCreate may looks like a solution for a page that will certainly be used, but not for seldom used ones...
 
Upvote 0
Top