iOS Question An iOS/B4X Question

Rattigan_Roger

Member
Licensed User
Longtime User
I am certain the answer is plainly explained somewhere here but I can't seem to find it.
I am working on my first B$X project, although I have written several Apps in B4i, B4A, B4J and B$R.

I have a two page app.
When the user finishes with the second page and uses a back arrow to the information he/she placed in the first page is discarded and the first page is used again. The info is entered through a series of switches.
Before the user goes back to the first page I reset all the switches and clear out the public variables.
The user then enters the info through the switches and then goes to the second page.
Try as I might, the info on the second page never gets changed.

The backbutton code is as follows

BACK BUTTON:
Private Sub backBtn_Click
    Utility.DisplaySchem = ""
    Utility.WrkingSchem = ""
    Utility.TheIconFile = ""
    B4XPages.ClosePage(Me)
    B4XPages.ShowPage("Mainpage")
End Sub
"Utility" is a public code module.
The switches are reset on the first page just prior to advancing to the second.
What am I doing wrong or not doing right?
Thanking You in advance for Your time and trouble.
 

Alexander Stolte

Expert
Licensed User
Longtime User
B4XPages.ClosePage(Me) B4XPages.ShowPage("Mainpage")
Use ShowPageAndRemovePreviousPages
B4X:
B4XPages.ShowPageAndRemovePreviousPages("Mainpage")

It would definitely be helpful if you could create an example project. Otherwise I can't figure out what you're doing wrong. Thanks.
 
Upvote 0

Alexander Stolte

Expert
Licensed User
Longtime User
Now I see the problem. You use the "LoadSchematic" function only in the B4XPage_Created event. But the event is only triggered once, when the page is used for the first time.

Either you use the B4XPage_Appear event or you call the function when you open the page, like:
B4X:
Private Sub Go_btn_Click
    File.WriteString(File.DirDocuments,"test.txt",Textfield1.text)
    Textfield1.text = ""
    B4XPages.ShowPage("schematic")
    SchemPage.LoadSchematic
End Sub
 
Upvote 1
Top