I'm trying to pass some parameters between two B4Xpages, there's some example from Erel where you define a Sub in the destination page and calls its before invoke the Showpage method, however this works only from the MainPage, if you are executing something in the Page2 for ex., and want to call a Sub on the Page3, you have no access to the Page3 methods. Putting some variables in the Main module is an ugly solution.
It is a good practice to declare pages in the B4XMainPage Class_Globals as public.
This way you can access them from anywhere (and do it what you need in this case).
You can declare Public variables (V1) in absolutely any B4XPage (P2) and access that variable from any other B4XPage (P3) as long as you declare P2 in P3, then you can simply do something like P2.V1. Not a problem...
I've tried it but there's something that eludes my mind (in B4A):
B4XMainPage:
B4X:
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Public txtUser As B4XFloatTextField
Private btnLogin As B4XView
Public Page2 As B4XPage2
Public Page3 As B4XPage3
Public PageIndicaciones As B4XPageIndicaciones
Public PageFormIndicaciones As B4XPageFormIndicaciones
Public PageFormIndicacionesMed As B4XPageFormIndicacionesMed
Private txtPassword As B4XFloatTextField
Private txtServerConfig As B4XFloatTextField
Private txtExtServerConfig As B4XFloatTextField
Private B4XLoadingIndicator1 As B4XLoadingIndicator
Private LError As Label
Public TransitionDuration As Int
End Sub
How do I access those instances?, if I'm inside B4XPage3 for example, I write "B4XMainPage." , "MainPage." , there's no way to access those members, I got no scope in B4A.
You can declare Public variables (V1) in absolutely any B4XPage (P2) and access that variable from any other B4XPage (P3) as long as you declare P2 in P3, then you can simply do something like P2.V1. Not a problem...
But if I declare one instance of B4XPage3 inside B4XPage2, and then set some public variables in B4XPage3, then invoke B4XPages.Show("Page3"), is the same class instance?,
How do I access those instances?, if I'm inside B4XPage3 for example, I write "B4XMainPage." , "MainPage." , there's no way to access those members, I got no scope in B4A.
Public Page2 As B4XPage2
Public Page3 As B4XPage3
Public PageIndicaciones As B4XPageIndicaciones
Public PageFormIndicaciones As B4XPageFormIndicaciones
Public PageFormIndicacionesMed As B4XPageFormIndicacionesMed
All those pages will be accessible (obviously their declaration is not enough, you will also have to initialize them and add them to the B4XPages, so writing
B4XPages.AddPage("Page2", Page2) or B4XPages.AddPage("Page2ID", Page2)).
B4XPages is a library that serves two purposes: 1. Make it simple to develop B4A apps by solving almost all of the challenges involved with Android complex activities life cycle. B4XPages makes B4A behave more similar to B4J and B4i where the new "B4XPage" element is a regular object that is...
www.b4x.com
Another way is to use GetPage.
Point #9 in tutorial.