SlidingMenu class

mrossen

Active Member
Licensed User
Longtime User
Hi,

I am using ActionBar and SlidingMenu from informatix.

These are very great, but I con figure out how to combine them.

In the example there is uses a button to open/close the menu.

When I am using the ActionBar the button is not defined as a button but as Dim pnlAB As Panel?

Any one know how to do this?

B4X:
btnMenu.Initialize("")
   btnMenu.SetBackgroundImage(LoadBitmap(File.DirAssets, "menu.png"))
   FakeActionBar.AddView(btnMenu, 100%x - BarSize, 0, BarSize, BarSize)
   PanelWithSidebar.SetOpenCloseButton(btnMenu)

B4X:
AB.AddButton(LoadBitmap(File.DirAssets, "add.png"), "", 5, -1, "AddProfile_Click", "")

I would like to use the "Addprofile_Click" in the "PanelWithSidebar.SetOpenCloseButton(btnMenu)" but I can not figure out how

:sign0163:

Mogens
 

mrossen

Active Member
Licensed User
Longtime User
I also have another problem I not can figure out.

How do I Initialize the 2 thing together?

B4X:
PanelWithSidebar.Initialize(AB, 200dip, 2, 1, 500, 500)

Mogens
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
When I am using the ActionBar the button is not defined as a button but as Dim pnlAB As Panel?

In the SlidingSidebar demo, my action bar is a simple panel (FakeActionBar) with a button (btnMenu). That's a bit different from the action bar created by the ActionBar class. To use these two classes together, that's pretty simple. Example:
B4X:
Dim MyMenuBtn As View
MyMenuBtn = MyActionBar.AddButton(LoadBitmap(File.DirAssets, "menu.png"), "", 5, -1, "", "") 'Don't define here the click handler
PanelWithSidebar.SetOpenCloseButton(MyMenuBtn)

Don't put the action bar into PanelWithSideBar. Like in the SlidingSidebar demo, it must be located outside and above.

And thanks a lot for your donation. :)
 
Last edited:
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Hi,

You are welkome. I am the one here to thank.

I still not got it 100%.

I am doing:
B4X:
PanelWithSidebar.Initialize(pnlListView, 200dip, 2, 1, 500, 500)

to init the panel. I have the pnlListView in my bal file.

This dont work. What am I doing wrong. Do I have to make the layout programmaly?

B4X:
' We init view
   Activity.LoadLayout("main")
   AB.Initialize(pnlAB, True, True, pnlAB.Height, Me)
   
   ' We create Sql base if it is missing
   If FirstTime Then
      CreateDatabase
   End If
   
   PanelWithSidebar.Initialize(pnlListView, 200dip, 2, 1, 500, 500)
   
   lvMenu.Initialize("lvMenu")
   lvMenu.AddSingleLine("Indstillinger")
   lvMenu.AddSingleLine("Sync Indstillinger")
   lvMenu.AddSingleLine("Varmer")
   lvMenu.AddSingleLine("Om")
   lvMenu.SingleLineLayout.Label.TextSize = 18
   lvMenu.SingleLineLayout.Label.TextColor = Colors.White
   lvMenu.Color = Colors.DarkGray
   lvMenu.ScrollingBackgroundColor = Colors.DarkGray
   PanelWithSidebar.Sidebar.AddView(lvMenu, 100%x - 200dip, 0dip, 190dip, -1)

Thank you for your time

Mogens
 
Upvote 0

Informatix

Expert
Licensed User
Longtime User
First, you need to create two panels for most basic layouts:
- one panel to hold the action bar
- under this panel, a panel filling the remaining space (I name it pnlMain)
These two panels can be created with the designer.

Second, when you call PanelWithSidebar.Initialize(pnlMain,...) two panels are created by the class:
- PanelWithSidebar.Sidebar holding the sidebar content (e.g. a ListView for a menu)
- PanelWithSidebar.Content holding the main content (the one you see when you open the activity)

pnlMain is the container of these two panels.

To help you further, please post a project.
 
Last edited:
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Hi again,

I am really stucked. I have anything I can think of.
I can not get it to work.

I attached my project. Hope you can help.

:sign0013:

Mogens
 

Attachments

  • cd.zip
    36.9 KB · Views: 311
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Hi again,

I am really stucked. I have anything I can think of.
I can not get it to work.

I attached my project. Hope you can help.

:sign0013:

Mogens

I looked at your code and I don't think the problem comes from my classes. When I remove everything under the MainActionBar sub, that works like a charm.

I changed the line:
PanelWithSidebar.ContentPanel.AddView(pnlListView, 30dip, 30dip, 100%x - 60dip, 100%y - 60dip)
because you cannot add to ContentPanel its own parent.
 
Upvote 0

mrossen

Active Member
Licensed User
Longtime User
Hi,

Finally I get it solved :)

The problem was that I had added my listview in the designer and its parent was pnllistview.

I removed the listview from the bal file and added it :

B4X:
ListViewProfiles.Initialize("ListViewProfiles")
   PanelWithSidebar.ContentPanel.AddView(ListViewProfiles, 0dip, 0dip, 100%x - 50dip, 100%y - 50dip)

Then is worked like a charm. This is exactly whas demo does but I could not see it.

Thank you for your time...

:sign0098:

Mogens
 
Upvote 0
Top