Guenter Becker Active Member Licensed User Longtime User Mar 2, 2022 #1 Hello, Using the B4XDrawer with B4XPage raises a question I like to ask. If we need only one Drawer as a central main Menu I do not like to implement the drawer subs/code in each B4XPage again and again. In a B4XPage Project the Idea is to implement the drawer not on each Page but one level higher on Activity level (Main). Ist that possible? Is there are better way? How? Thank you for the answer.
Hello, Using the B4XDrawer with B4XPage raises a question I like to ask. If we need only one Drawer as a central main Menu I do not like to implement the drawer subs/code in each B4XPage again and again. In a B4XPage Project the Idea is to implement the drawer not on each Page but one level higher on Activity level (Main). Ist that possible? Is there are better way? How? Thank you for the answer.
Erel B4X founder Staff member Licensed User Longtime User Mar 3, 2022 #2 You have two options: 1. Implement it in the main activity. This will only work in B4A. 2. Implement it in a class and create a class instance on each of the pages. Example here: https://www.b4x.com/android/forum/threads/138771/#content The second option will require some additional work to make it cross platform but it should be possible to do. Upvote 0
You have two options: 1. Implement it in the main activity. This will only work in B4A. 2. Implement it in a class and create a class instance on each of the pages. Example here: https://www.b4x.com/android/forum/threads/138771/#content The second option will require some additional work to make it cross platform but it should be possible to do.
Guenter Becker Active Member Licensed User Longtime User Mar 3, 2022 #3 Ok thank you. To implement it in the main is what I prefer. I tried it but run into problem. Code: Copy Drawer.Initialize(Me,"Drawer",Me,400dip) ' this wrong and raises an error 'Drawer.CenterPanel.LoadLayout("MainPage") Drawer.LeftPanel.LoadLayout("MainMenu") To initialize the drawer I understand to set the callback to Me but what is the correct reference to set for the 2nd it's a b4xview I do'nt have it in Main. The next is what to load? LeftPanel is the Drawer OK, but the central panel? SHould it be the B4XMainPage? Upvote 0
Ok thank you. To implement it in the main is what I prefer. I tried it but run into problem. Code: Copy Drawer.Initialize(Me,"Drawer",Me,400dip) ' this wrong and raises an error 'Drawer.CenterPanel.LoadLayout("MainPage") Drawer.LeftPanel.LoadLayout("MainMenu") To initialize the drawer I understand to set the callback to Me but what is the correct reference to set for the 2nd it's a b4xview I do'nt have it in Main. The next is what to load? LeftPanel is the Drawer OK, but the central panel? SHould it be the B4XMainPage?
DonManfred Expert Licensed User Longtime User Mar 3, 2022 #4 Guenter Becker said: this wrong and raises an error Click to expand... Hiding the full error is a good way not to get help. Try to reproduce it in a small project and upload the project. Upvote 0
Guenter Becker said: this wrong and raises an error Click to expand... Hiding the full error is a good way not to get help. Try to reproduce it in a small project and upload the project.
Guenter Becker Active Member Licensed User Longtime User Mar 3, 2022 #5 Sorry, I know that this is wrong! It was only an example. If you let it run you get the error dat the 2nd Me is not accepted because the Me is pointing to an activity and not to an B4XView. Upvote 0
Sorry, I know that this is wrong! It was only an example. If you let it run you get the error dat the 2nd Me is not accepted because the Me is pointing to an activity and not to an B4XView.
LucaMs Expert Licensed User Longtime User Mar 3, 2022 #6 Guenter Becker said: Sorry, I know that this is wrong! It was only an example. If you let it run you get the error dat the 2nd Me is not accepted because the Me is pointing to an activity and not to an B4XView. Click to expand... It shoud be: Drawer.Initialize(Me,"Drawer", Activity.As(B4XView),400dip) Last edited: Mar 3, 2022 Upvote 0
Guenter Becker said: Sorry, I know that this is wrong! It was only an example. If you let it run you get the error dat the 2nd Me is not accepted because the Me is pointing to an activity and not to an B4XView. Click to expand... It shoud be: Drawer.Initialize(Me,"Drawer", Activity.As(B4XView),400dip)
Guenter Becker Active Member Licensed User Longtime User Mar 3, 2022 #7 ok, thank you. One thing left, how to open the drawer from a button on the b4xpage? Upvote 0
DonManfred Expert Licensed User Longtime User Mar 3, 2022 #8 Guenter Becker said: how to open the drawer from a button on the b4xpage? Click to expand... B4X: Copy ' Two subs in the drawer Public Sub getLeftOpen As Boolean Return IsOpen End Sub Public Sub setLeftOpen (b As Boolean) If b = IsOpen Then Return Dim x As Float If b Then x = 0 Else x = -mSideWidth ChangeOffset(x, False, False) End Sub Upvote 0
Guenter Becker said: how to open the drawer from a button on the b4xpage? Click to expand... B4X: Copy ' Two subs in the drawer Public Sub getLeftOpen As Boolean Return IsOpen End Sub Public Sub setLeftOpen (b As Boolean) If b = IsOpen Then Return Dim x As Float If b Then x = 0 Else x = -mSideWidth ChangeOffset(x, False, False) End Sub