B4A Library [CLASS] Animated Sliding Menu

This class will allow you to create animated sliding menus.

Requirements:

- B4A 2.xx
- Universal Tween Lib
- Phone Lib
- Add the Class module "AnimatedSlidingMenu.bas" to your project

How to use:

Initialize the class:

B4X:
Sub Globals

    Dim MyMenu As AnimatedSlidingMenu

End Sub

Then, create your animated sliding menu:
B4X:
'The menu title is optional, pass an empty sting if no title is needed
'If you add a picture to the title's background then enter an * on the title text or
'the title won't show up
myMenu.Initialize(Activity, Me, "Menu Title", "Test", "L", 50dip, 300dip, Colors.Blue, Null)

'Then add items to the menu
myMenu.AddItem(Null, "Item One", Colors.White, Colors.Transparent, 1)
myMenu.AddItem(Null, "Item Two", Colors.White, Colors.Transparent, 2)
myMenu.AddItem(Null, "Item Three", Colors.White, Colors.Transparent, 3)
myMenu.AddItem(Null, "Item Four", Colors.White, Colors.Transparent, 4)

...

'This routine will get the selected menu item, in this case, "Test" is the name of the event
'that will catch the selection, you can name yours with whatever name you like
Sub Test_Click(SelectedItem As Object)
            
    ToastMessageShow("Item selected: " & SelectedItem, False)

End Sub
If you added a title, you can modify its properties like this:
B4X:
myMenu.SetTitle(Colors.Red, Colors.White, Gravity.CENTER_HORIZONTAL, Null)

To open the menu use the following code:
B4X:
Sub Button1_Click

    myMenu.OpenMenu("Casino")
   
End Sub

There are 8 pre-defined animations included in this class: Default, Casino, CasinoReverse, ShootUp, Cascade, Flip, Fade and ZigZag.

This class supports up to 50 menu items.

That's it!!.

The attached file contains a DEMO and a BAREBONES sample to better understand the use of this class.

Updated on Nov 26, 2012 to version 1.2

Screen shots:

C43h2l.jpg
FW2jgl.png

ptTTPl.png
nSH0Zl.png
 

Attachments

  • AnimatedSlidingMenuClass.zip
    165.6 KB · Views: 1,962
Last edited:

bluedude

Well-Known Member
Licensed User
Longtime User
Great stuff NJDude, one small question. How come all TABS in your code are all over the place? The code is pretty much unreadable without reformatting it.

Cheers and thanks!
 

bluedude

Well-Known Member
Licensed User
Longtime User
Tracking when menu is closed

Hi,

I need to find a way to see when the menu is closed by touch. The reason is that I want to slide all of my interface to the right when opening the menu. But, I also want to do this if the menu is closed by touch.

How could I do this?

Cheers.
 

GMan

Well-Known Member
Licensed User
Longtime User
Is it possible to make the scrolling part sizeable in heigth ?
i.e. start at 30dip from the top and ends 30dip above the bottom
 

GMan

Well-Known Member
Licensed User
Longtime User
I tried already, but dont know where exactly.
All failed
 

itgirl

Active Member
Licensed User
Longtime User
Amazing Class, i don't know how i didn't came across it before :(
this kind of classes should be marked some how to be more visible ;)
 

Andy S.

Member
Licensed User
Longtime User
Cool NJDude! What license model are you distributing this class under?

Thanks,
Andy
 
Top