B4J Question Load multiple layout at same time one inside another

Schakalaka

Active Member
Licensed User
Longtime User
Hello,
i have create this layout.

How can I load multiple layouts when click on left menu item, and load the layout code in "code module"?

Any alternatives?

1681745096697.png


Thank you
**project added
 

Attachments

  • project.zip
    369.1 KB · Views: 133
Last edited:

TILogistic

Expert
Licensed User
Longtime User
see
 
Upvote 0

nbarakat

Member
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
 
Upvote 0

giannimaione

Well-Known Member
Licensed User
Longtime User
Well, if we have to advise him to change his sw, rather than just answering his question, then I would recommend him B4XDrawer.
i will study B4XDrawer;
many times Erel has proposed solutions to replace the previous ones
 
Upvote 0

PaulMeuris

Active Member
Licensed User
Here is an implementation of Andrew's suggestion:
B4X:
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.
1681818247145.png

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!
 
Last edited:
Upvote 0
Top