Android Question what is the right way to use Drawer?

omarruben

Active Member
Licensed User
Longtime User
following many samples , I just want to confirm if I am doing the right thing to manage multiple SECTIONS of and app, is this the right way? thank you:

B4X:
Sub Activity_Create(FirstTime As Boolean)
    'Do not forget to load the layout file created with the visual designer. For example:
    Drawer.Initialize(Me, "Drawer", Activity, 300dip)
    Drawer.CenterPanel.LoadLayout("MainLayout")
    Drawer.LeftPanel.LoadLayout("LeftMenu")
    lsv_MenuListView.AddSingleLine("Home")
    lsv_MenuListView.AddSingleLine("Contact Us")
    lsv_MenuListView.AddSingleLine("Privacy Policy")  

End Sub
B4X:
Sub lsv_MenuListView_ItemClick(position As Int, value As Object)
If position = 0 Then
        Drawer.CenterPanel.RemoveAllViews
        Drawer.CenterPanel.LoadLayout("MainLayout")
        Drawer.LeftOpen=False
    End If
   
    If position = 1 Then
        Drawer.CenterPanel.RemoveAllViews
        Drawer.CenterPanel.LoadLayout("contactus")
        Drawer.LeftOpen=False
   
    End If
End Sub

when a item on the list is clicked , erase all views from CenterPanel and load the new design?
thank you
 

Daica

Active Member
Licensed User
Doing it this way causes the hamburger icon to disappear, as well as putting the ACToolBarLight1 on top of everything.
B4X:
Drawer.CenterPanel.RemoveAllViews
does not remove the view at all, and then loading the 2nd activity just puts it on top of the current one
 
Last edited:
Upvote 0
Top