B4J Question Problem with menubar to load layout [B4Xpage Project]

universengo

Member
Hello experts!
I'm a newbie, looking for some help.
I use B4XPages Project to create an app with 1 main layout with menubar and sub-layouts corresponding to click menus.
For each layout, I create a corresponding B4Xpage module class to easily name components and code commands.
The problem is:
1) If I use it as Root.loadlayout("layoutxxx") to load the layouts from the respective click menu, it displays properly (i.e. both show the main layout's menubar and the child layout's form). However, I wouldn't know how to get the coded controls in the layout to work.
2) If I use the function B4Xpages.showpage("layoutxxx") then the layout will only show itself (and the main layout with the menu will be below), now the buttons from the module class will work OK.
=> The question is: I want to make it so that when I open the child layout, the menubar still exists as in case 1, and the buttons in the modules still work as in case 2.
 

Attachments

  • Question.png
    Question.png
    67.3 KB · Views: 135
  • case2.png
    case2.png
    86.9 KB · Views: 138
  • case1.png
    case1.png
    86.7 KB · Views: 145

teddybear

Well-Known Member
Licensed User
Hello experts!
I'm a newbie, looking for some help.
I use B4XPages Project to create an app with 1 main layout with menubar and sub-layouts corresponding to click menus.
For each layout, I create a corresponding B4Xpage module class to easily name components and code commands.
The problem is:
1) If I use it as Root.loadlayout("layoutxxx") to load the layouts from the respective click menu, it displays properly (i.e. both show the main layout's menubar and the child layout's form). However, I wouldn't know how to get the coded controls in the layout to work.
2) If I use the function B4Xpages.showpage("layoutxxx") then the layout will only show itself (and the main layout with the menu will be below), now the buttons from the module class will work OK.
=> The question is: I want to make it so that when I open the child layout, the menubar still exists as in case 1, and the buttons in the modules still work as in case 2.
Please read 11 B4XPagesNavBar in booklet B4XPages Cross-platform projects
you can download the example of sorucecode.
 
Last edited:
Upvote 0

teddybear

Well-Known Member
Licensed User
I don't know how you designe mainlayout. I guess you should add a pane beneath menubar in mainlayout.
it looks like this

Root.LocadLayout("mainlayout")
Pane1.LocadLayout("layoutxxxx"). or b4xpage module .Initialize(Root) (See also B4XPagesNavBar)

You'd better post a small project.
 
Last edited:
Upvote 0

klaus

Expert
Licensed User
Longtime User
Have you downloaded the source codes for the B4X Booklets ?
Did you look at the code of the B4XPagesNavBar project ?
This program has four B4XPages and a NavBar Class which is displayed on each B4XPage and allows to navigate between the pages.
 
Upvote 1

universengo

Member
I share my app and note in B4XMainpage
Case1: (have demo case1.jar)
- if I use these code then the layout1, layout2, layout3 will show ABOVE mainpage
- and these button on layout1, layout2, layout3 CAN use corresponding in classs module B4XPage1, B4XPage2, B4XPage3

Case 1:
Sub B4XPage_MenuClick (Tag As String)
    Select Tag
        Case "Layout 1"
            B4XPages.ShowPage("Layout 1")
        Case "Layout 2"
            B4XPages.ShowPage("Layout 2")
        Case "Layout 3"
            B4XPages.ShowPage("Layout 3")
    End Select
End Sub
Case2: (have demo case2.jar)
- if I use this code then layout1, layout2, layout3 will show as CHILD of mainpage
- and these button on layout1, layout2, layout3 CAN NOT use corresponding in classs module B4XPage1, B4XPage2, B4XPage3

Case2:
Sub B4XPage_MenuClick (Tag As String)
    'clear layout
    Root.RemoveAllViews
    Select Tag
        Case "Layout 1"
            Root.LoadLayout("Layout1")
        Case "Layout 2"
            Root.LoadLayout("Layout2")
        Case "Layout 3"
            Root.LoadLayout("Layout3")
    End Select
    'load layout
    Root.LoadLayout("MainPage")
    B4XPages.SetTitle(Me, Tag & " - [Mainpage]")
End Sub
My Wish:
- I would like to use this Case 2 and can use the button as Case 1
- (can click button on layout1, layout2, layout3 corresponding in classs module B4XPage1, B4XPage2, B4XPage3 )

help me to to this. Thanks.

 

Attachments

  • Case1.jar
    461.4 KB · Views: 157
  • Case2.jar
    461.5 KB · Views: 151
  • MyCode.rar
    72.8 KB · Views: 148
Upvote 0

universengo

Member
Have you downloaded the source codes for the B4X Booklets ?
Did you look at the code of the B4XPagesNavBar project ?
This program has four B4XPages and a NavBar Class which is displayed on each B4XPage and allows to navigate between the pages.
thanks klaus but they have not menubar for all layout load
 
Upvote 0

teddybear

Well-Known Member
Licensed User
thanks klaus but they have not menubar for all layout load
You should read the code of the B4XPagesNavBar carefully first, as NavBar, you also need to create menubar page, then on each page initializing(add) it.

In MyCode.rar you missed B4xMainPage code. To package a small project you should do
B4X:
 'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
it is on top of B4xMainPage you can find it.
 
Upvote 0

universengo

Member
You should read the code of the B4XPagesNavBar carefully first, as NavBar, you also need to create menubar page, then on each page initializing(add) it.

In MyCode.rar you missed B4xMainPage code. To package a small project you should do
B4X:
 'Ctrl + click to export as zip: ide://run?File=%B4X%\Zipper.jar&Args=Project.zip
it is on top of B4xMainPage you can find it.
Reupload my code, help me how to solve it. thanks.
 

Attachments

  • Case1.jar
    461.4 KB · Views: 138
  • Case2.jar
    461.5 KB · Views: 136
  • MyCode_new.zip
    13.8 KB · Views: 151
Upvote 0

teddybear

Well-Known Member
Licensed User
It's better to complete the project by yourself.
 

Attachments

  • Project.zip
    14.9 KB · Views: 147
Upvote 0
Top