Android Question [SOLVED]B4XPages, GetPage purpose?

incendio

Well-Known Member
Licensed User
Longtime User
Hi guys,

I ran the example from this thread :

On B4xPage2 class there is there these code
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("Page2")
    Page3 = B4XPages.GetPage("Page 3")
End Sub

What is the use of this code?
B4X:
Page3 = B4XPages.GetPage("Page 3")

Isn't it the Page3 already declared as a class of B4XPage3 ? Just like common class, why should get the instance again?
The code made it possible to use Page3 subs before it is initialized, is this the only purpose?

Changed the codes into these
B4X:
Private Sub B4XPage_Created (Root1 As B4XView)
    Root = Root1
    'load the layout to Root
    Root.LoadLayout("Page2")
    Page3.Initialize
    'Page3 = B4XPages.GetPage("Page 3")
End Sub

App runs OK.
 
Last edited:

incendio

Well-Known Member
Licensed User
Longtime User
Your code will not work. We don't want to create another different instance of B4XPage3. We want to access a very specific instance of B4XPage3 and one way to get it is with B4XPages.GetPage.
It work OK, but it created another instance of B4XPage3.

I see now, you want to access the instance that was declared in B4XMainPage. OK, thanks for the explanation.
 
Upvote 0
Top