Hi guys,
I have pgUtils that called by multiple pages.
Here are the codes from pgUtils
Calling from page1
Calling from page2
If for the first time, pgutils called from page1, then called again from page2, variable PgMsg still hold a value from page1, though in sub Initialize already changed. Even after the app closed, variable PgMsg still hold value from the first caller. I have to forced close app to reset it.
Where is the problem?
Attached is the sample project.
I have pgUtils that called by multiple pages.
Here are the codes from pgUtils
B4X:
Sub Class_Globals
Private Root As B4XView 'ignore
Private xui As XUI 'ignore
Private PgMsg As String
End Sub
Public Sub Initialize(Msg As String) As Object
PgMsg = Msg
Return Me
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("ly_util")
End Sub
Sub B4XPage_Appear
xui.MsgboxAsync(PgMsg, "B4X")
End Sub
Calling from page1
B4X:
Private Sub Button1_Click
pageutil.Initialize("this is from page1")
If B4XPages.GetManager.FindPIFromB4XPage(pageutil) = Null Then
B4XPages.AddPage("pageutil",pageutil)
End If
B4XPages.ShowPage("pageutil")
End Sub
Calling from page2
B4X:
Private Sub Button1_Click
pageutil.Initialize("this is from page2")
If B4XPages.GetManager.FindPIFromB4XPage(pageutil) = Null Then
B4XPages.AddPage("pageutil",pageutil)
End If
B4XPages.ShowPage("pageutil")
End Sub
If for the first time, pgutils called from page1, then called again from page2, variable PgMsg still hold a value from page1, though in sub Initialize already changed. Even after the app closed, variable PgMsg still hold value from the first caller. I have to forced close app to reset it.
Where is the problem?
Attached is the sample project.