An Android style menu class


Active Member
Licensed User
I should say that starting on B4i after a couple of years learning B4A was not easy.
Even though Erel has done a great job smoothing out the differences, Android and iOS simply want to do things differently.
Not wanting to pass judgement on which is best, my goal was simply to reproduce a similar environment for me to be able to migrate apps from Android to iOS and to give them a similar feel.
A couple of features that I like to use in B4A and which are missing (or implemented too differently to my taste) are the menus and the Toast messages.
So I created a new class to emulate the Android menus.
I also found a ToastMessage class for B4i written by Pendrush (thanks a lot!), which I tweaked to make it really look more like the one on Android.
The project below shows the two classes in action.

1. Declare the class in Process_Globals:
    Private Menu As clsMenu
2. Initialize the class and load the menu options in Application_Start:
    Menu.Initialize( PageMain, 17 )
    Menu.AddMenuItem( "Sub1", "mnuSub1" )
    Menu.AddMenuItem( "Sub2", "mnuSub2" )
    Menu.AddMenuItem( "About", "mnuAbout" )
3. Open the menu by clicking on the Navigation bar element (set in the designer)
Sub PageMain_BarButtonClick( Tag As String)
    If Tag = "Menu" Then
        If Menu.Visible = False Then
        End If
    End If
End Sub ' Page_BarButtonClick
Note: The Menu class is usable with very few modifications on Android. You may ask why. It turns out I have a couple of older Android devices intended for home automation (Wink Relay) running a crippled version of Android 4.4 which does not support the menus (they do not have the navigation bar either), so I imported the clsMenu class, replaced the TableView with a ListView and adapted the code to the few associated differences and voila. I will post the Android clsMenu class later if there is interest.


Last edited:


Active Member
Licensed User
On Android, the ToastMessage are maybe 10dip on the bottom, but this ToastMessage are 60%y (felt), is this normal? (6S Plus)
I set it there because I tend to have other status info displayed at the bottom of the screen on my apps and I did not want to cover than.
This can easily be changed in the clsMenu module.