Android Question [B4X] B4XPages - Current Page / Top Page - Calling routine indirectly

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Is this how I get the current page
Dim CurrentPageInfo As B4XPageInfo = B4XPages.GetManager.GetTopPage

The Popup Doc says GetManager probably shouldn't be used. But the B4XPageInfo has the Id and B4XPage of the current (top) page?

Is there a better way of doing this?


And how to call a page routine indirectly
If SubExists(CurrentPageInfo.B4XPage, "DoSomething") Then
Dim SomeValue As Int = CallSub(CurrentPageInfo.B4XPage, "DoSomething")
End If
 

agraham

Expert
Licensed User
Longtime User
Is this how I get the current page
Yes. Erel intends B4XPages to be the user API for B4XPAges, but all the B4XPages functions redirect to the similar named B4XPagesManager firelds/functions except GetPageId which uses FindPIFromB4XPage(page).Id.

Your indirect call should work fine, that's what I did when first playing with B4XPages, but if you know the class of the page you can just cast the B4XPage to it and use direct calls
 
Upvote 0

Robert Valentino

Well-Known Member
Licensed User
Longtime User
Thanks that helps a lot.

Was surprised that I had to call GetManager to get the top page. Would have thought that would be a B4XPages.GetTopPage command. But it works.

All my classes have the same function names but are different classes (if we had c++ type inheritance I could cast to a base class and call directly - maybe down the road)
 
Upvote 0
Top