Android Question Drawer is not working on second time click

AndroidMadhu

Active Member
Licensed User
Hello,
I am using B4XDrawer for opening a drawer from lefthandside.
While I click the drawer for the first time after installation/compilation the drawer is working as expected. After that I click the menu option[CLV]
But If I click the drawer for the second time, the drawer is not working.
The below is the code base :
B4X:
drawer.Initialize(Me, "Drawer", Root, 300dip)
drawer.CenterPanel.LoadLayout("MainPage")
drawer.LeftPanel.LoadLayout("leftPage")
custMenu.AddTextItem("       Settings",0)
**********************************************
 Sub lblDrawer_Click
drawer.LeftOpen=True
'lblDrawer.Enabled=True
End Sub

The menu I have added to the Drawer:

B4X:
Sub custMenu_ItemClick (Index As Int, Value As Object)
Select Index
Case 0
Root.LoadLayout("settings")
setCounter
End Select
End Sub

Please advice on this.

Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
I don't understand your code. Why is the same layout file loaded 3 times? Don't load anything to root. You need to load the layout to drawer.CenterPanel.

Loading a layout doesn't remove the previous loaded views.
If you want to replace the layout (which is usually a bad idea):
B4X:
Sub btnUpdateSettings_Click
    drawer.CenterPanel.RemoveAllViews
    drawer.CenterPanel.LoadLayout("MainPage")
End Sub
 
Upvote 0
Top