iOS Question How to start another (activity) in B4I

DickD

Active Member
Licensed User
I am an experienced B4A user but am just starting with B4I. Pardon what I'm sure is a dumb question. I need to start another program, app, activity in B4I. In B4A I would simply use StartActivity(acitivityName). I've tried using the code below but I can't find any evidence that the program PersonalInfoIP ever runs but there is no error message. What am I doing wrong? I have tried several tests including putting the Page2 information in the Main program.

B4X:
'this is the main program.  There is a button PersInfo in the layout Main2 and clicking it does start the sub PersInfo_click
Sub Process_Globals
 Public App As Application
 Public NavControl As NavigationController
 Private Page1 As Page
 Public PersInfo As Button
End Sub
Private Sub Application_Start (Nav As NavigationController)
 'SetDebugAutoFlushLogs(True) 'Uncomment if program crashes before all logs are printed.
 NavControl = Nav
 Page1.Initialize("Page1")
 Page1.Title = "Page 1"
 Page1.RootPanel.Color = Colors.White
 Page1.RootPanel.LoadLayout("Main2")
 NavControl.ShowPage(Page1)
End Sub
Private Sub Page1_Resize(Width As Int, Height As Int)
 
End Sub
Private Sub Application_Background
 
End Sub
Sub PersInfo_Click
 PersInfo.Text = "Made it to sub" 'this works
 PersonalInfoIP.Start()
End Sub

B4X:
'this is the second program PersonalInfoIP which never seems to run.  The layout is never displayed
Sub [B]Process_Globals[/B]
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public Page2 As Page
Public TestButton As Button
End Sub
Sub [B]Start[/B]
Page2.initialize("Page2")
Page2.Title = "Personal Info"
Page2.RootPanel.Color = Colors.Black
Page2.RootPanel.LoadLayout("PersonalInfoTest")
End Sub
Sub [B]TestButton_click[/B]
TestButton.Text = "You made it"
return
End Sub
 

DickD

Active Member
Licensed User
That did help me to launch the second app PersonalInfoTest. But the the layout file displays on the screen only briefly before immiediately returning to the main program. See below.

B4X:
Sub Process_Globals
'These global variables will be declared once when the application starts.
'Public variables can be accessed from all modules.
Public pg As Page
Public Page2 As Page
Public TestButton As Button
End Sub
Sub Start
If pg.IsInitialized = False Then
pg.Initialize("pg")
pg.RootPanel.LoadLayout("PersonalInfoTest")
End If
Main.NavControl.ShowPage(pg)
End Sub
Sub TestButton_click
TestButton.Text = "You made it"
pg.ResignFocus
Main.Show
End Sub
 
Upvote 0

jahswant

Well-Known Member
Licensed User
Longtime User
You can add a simple panel to your page and load the layout on it. Then hide it. When necccessary call panel.Visible = True and panel.BringToFront.
 
Upvote 0

DickD

Active Member
Licensed User
You can add a simple panel to your page and load the layout on it. Then hide it. When necccessary call panel.Visible = True and panel.BringToFront.
I am an absolute beginnger with IOS and don't really understand what you are talking about. As far as I can see form the beginners guide panels have to do with graphics and drawing on a canvas. I just want to display a page/screen/window with a single simple label and a single button. Can you provide an example?
 
Upvote 0

DickD

Active Member
Licensed User
I did figure this out. The only thing I was missing was the Page1.ResignFocus before starting the second program. It was critical.
 
Upvote 0
Top