Android Question b4x pages ShowPageAndRemovePreviousPages

Addo

Well-Known Member
Licensed User
Longtime User
good afternoon, I have started to use b4xpages currently I have 2 pages.
with the following code

B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("Page1")
    Page2.Initialize
    B4XPages.AddPage("Page2", Page2)
    'Here i will call sub to show page2
    loadMysecondpage
    
End sub

public Sub loadMysecondpage
B4XPages.ShowPageAndRemovePreviousPages("Page2")
End sub

but every time I try to show Page2 it doesn't show up unless I press the back button on the phone.
why I am doing wrong?
 

josejad

Expert
Licensed User
Longtime User
Not sure if it's the same problem, do you have v1.08 of B4XPages library?

 
Upvote 0

josejad

Expert
Licensed User
Longtime User
Yes, try it. In the link I've posted you can find it.
Or have you updated to B4A 10.6? Maybe it already come with B4XPages 1.08
 
Upvote 0

Addo

Well-Known Member
Licensed User
Longtime User
I figure it out i should have called loadMysecondpage

in the event B4XPage_Appear , but I really don't understand why was that needed what is the difference between calling it in Create event or in Appear event ..
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
Do not create B4XPage_Appear, call it so:
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("Page1")
    Page2.Initialize
    B4XPages.AddPage("Page2", Page2)
    'Here i will call sub to show page2
    CallSubDelayed(Me, "loadMysecondpage")
    
End sub
 
Upvote 0

Mahares

Expert
Licensed User
Longtime User
Do not create B4XPage_Appear, call it so:
I figure it out i should have called loadMysecondpage
Something like this would have also worked. What do you think @LucaMs the only 'Mario'
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    Root.LoadLayout("Page1")
    P2.Initialize
    B4XPages.AddPage("Page2", P2)
    Sleep(0)
    B4XPages.ShowPageAndRemovePreviousPages("Page2")
End Sub
 
Upvote 0

LucaMs

Expert
Licensed User
Longtime User
I don't know if he wants to call his routine more than once, it is declared as Public and in his real project could contain other stuff.

Anyway, at that time of night I read rarely, quickly and my two neurons are already asleep :) (although the suggestion works, using Sleep is easier here)
 
Last edited:
Upvote 0
Top