Android Question Sliding left menu + B4XPages, changing "screens"

Daica

Active Member
Licensed User
Hello everyone. I am currently trying to setup my app so that I have a left sliding menu like so: https://www.b4x.com/android/forum/threads/b4x-b4xdrawer-sliding-drawer.97828/
I would like to change the "screen" or "view" the user is seeing by using the left menu. I found this tutorial: https://www.b4x.com/android/forum/threads/b4x-b4xpages-b4xdrawer.120246/#content

It works fine, however, the problem is loading a different screen into view.
Let's say I have 3 screens, Login, Main, Settings.
Once I do Drawer.CenterPanel.LoadLayout("Login"), The only way to load a new layout is to remove all the view with CenterPanel.RemoveAllViews, and then loading it again.

This solution does not work well because what if you're on the Main screen typing/working with something? Removing all the view would erase all of that.
Is there a good solution to having a left sliding menu, and being able to change the "screen" the user is seeing once those menu items are clicked?

Currently, I have different panels outside of the designer view. When the menu item is clicked, I move the panel's .Top and .Left to (0,0). This causes problem though if the panel needs to resize.
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Currently, I have different panels outside of the designer view. When the menu item is clicked, I move the panel's .Top and .Left to (0,0). This causes problem though if the panel needs to resize.
This is never the correct way. You should instead use multiple layout files.

Implement the drawer in a class and create a class instance in each of the pages. This will allow you to switch to different pages.
 
Upvote 0

Daica

Active Member
Licensed User
Thanks Erel. I went with the multiple layout + multiple panel solution. It's simpler for me to understand this approach.
 
Upvote 0
Top