A good thing could be to create a class for each menu item, with its own layout (you will pass PanePrimo to the class, which you will maybe neme pnContenitore and in this you will load the layout) and its own source code.
I built an app in B4J using B4XPages. It uses multiple windows. Right now, an initial window has a set of buttons. Once one of these is clicked, a new window pops up displaying the layout for that functionality. Once that is closed, we return to the main window. We are now considering using a...
If I understood your question correctly, I would use a TabPane and then load the Tabpane with the tabs each from its own class. Maybe something like this.
B4X:
'TabPane one in the designer
#If B4J
Dim TP As TabPane=TabPane1.As(TabPane)
#End If
In Each class your initialization Routine might look something like this.
Load Login View:
'Initializes the object. You can add parameters to this method if needed.
'You send the TabPane That was created in your MainPage '
Public Sub Initialize(TP As TabPane)
'Create a TabPage and load it with a Name'
Dim TPage As TabPage
TPage=TP.LoadLayout("Login.bjl","Login")
'If you want give the page a Tag Identification so you could activate or remove'
TPage.Tag="A01"
TP.SelectedIndex=TP.Tabs.Size-1
....Do whatever to initialize you class
End Sub
Sub Class_Globals
Private Root As B4XView
Private xui As XUI
Private Button1 As Button
Private Button2 As Button
Private Button3 As Button
Private Button4 As Button
Private pncontent As Pane
End Sub
Public Sub Initialize
B4XPages.GetManager.LogEvents = True
End Sub
Private Sub B4XPage_Created (Root1 As B4XView)
Root = Root1
Root.LoadLayout("MainPage")
End Sub
Private Sub Button1_Click
pncontent.RemoveAllNodes
pncontent.LoadLayout("page1_layout")
End Sub
Private Sub Button2_Click
pncontent.RemoveAllNodes
pncontent.LoadLayout("page2_layout")
End Sub
Private Sub Button3_Click
pncontent.RemoveAllNodes
pncontent.LoadLayout("page3_layout")
End Sub
Private Sub Button4_Click
pncontent.RemoveAllNodes
pncontent.LoadLayout("page4_layout")
End Sub
Create the layouts and you are good to go.
The MainPage layout contains the 4 buttons and the pncontent pane.
The page layouts contain a pane and a label inside the pane for instance.
Sometimes it is best to keep it simple...
You can also use the menu items in stead of the button click events.
Happy coding!