Create a new empty project with B4XPages template and you’ll see how to use LoadLayout in that context.
you don’t need to address Activity anymore
I have done this and it tells me nothing that I do not already show, which gives errors when compiling. So something is needed.
After I started the new project, I added some code to do what I need. But it won't compile. So what is wrong?
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Dim Activity As Activity
End Sub
Public Sub Initialize
' B4XPages.GetManager.LogEvents = True
End Sub
'This event will be called once, before the page becomes visible.
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
Activity.LoadLayout("options_panel1")
Activity.LoadLayout("options_panel2")
End Sub
'You can see the list of page related events in the B4XPagesManager object. The event name is B4XPage.
Private Sub Button1_Click
xui.MsgboxAsync("Hello world!", "B4X")
The errors are (it does not like "Dim Activity As Activity", but if I comment that out, then it says that Activity is an undeclared variable. So I can't seem to win.:
Compiling debugger engine code. Error
B4A line: 12
Dim Activity As Activity
shell\src\b4a\example\b4xmainpage_subs_0.java:64: error: cannot find symbol
b4xmainpage._activity = RemoteObject.createNew ("anywheresoftware.b4a.objects.ActivityWrapper");__ref.setField("_activity",b4xmainpage._activity);
^
symbol: variable _activity
location: class b4xmainpage
1 error
only showing the first 1 errors, of 2 total; use -Xmaxerrs if you would like to see more
When 'Dim Activity As Activity' is commented out, then I see this error:
Parsing code. Error
Error parsing program.
Error description: Undeclared variable 'activity' is used before it was assigned any value.
Error occurred on line: 24 (B4XMainPage)
Activity.LoadLayout("options_panel1")