Android Tutorial [B4X] [B4XPages] What exactly does it solve?

Status
Not open for further replies.

sorex

Expert
Licensed User
Longtime User
I was trying to add a new page and show it immediatly but couldn't figure out why it wouldn't work.

Can you explain why I need the sleep(0) in this snippet to make it work? without it the page won't display and it just shows the empty default page.

B4X:
Private Sub B4XPage_Created (root1 As B4XView)  'B4XMainPage.bas/default page code
    pageMenu.Initialize
    B4XPages.AddPageAndCreate("Menu",pageMenu)
    Sleep(0)   ' <-- page won't display without this line
    B4XPages.ShowPage("Menu")

    pageInfo.Initialize(root1)  ' <-- these 2 lines are here to test paging, without it the sleep(0) is still required
    B4XPages.AddPage("Info",pageInfo)
End Sub

I also tried to call the showpage inside the menu page's _created sub but it didn't work without the additional sleep in that sub either.

Alternatively I can call my menu class to set up the default page but then showpage will not require "Menu" but that main page variable which makes it confusing again.

another strange thing is that when you put a log line in the menu class's _created and _appear sub that they both appear in the log but the page doesn't really appear.
 
Last edited:

agraham

Expert
Licensed User
Longtime User
I think the Sleep allows it to go off and finish creating and showing the default MainPage then it returns and takes notice of ShowPage. Without it I suspect the ShowPage is ignored as it completes the MainPage creation process. Putting the add and show page code in MainPage Initialize does work. Have you seen Erel's post on it at post #10 in this thread?
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I was trying to add a new page and show it immediatly but couldn't figure out why it wouldn't work.

Can you explain why I need the sleep(0) in this snippet to make it work? without it the page won't display and it just shows the empty default page.
This is not the correct place for this question.
Please start a new thread.
 
Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…