B4A Library StdActionBar - Another ActionBar library

StdActionBar (Standard ActionBar) library is based on the native ActionBar API, therefore it is only supported by Android 4+.

StdActionBar / StdViewPager tutorial: ActionBar / Sliding Pages tutorial

The share of Android 2.x devices is dropping and currently (January 2014) it is only 24%.

This library allows you to add tabs and dropdown list to the action bar:


The attached example demonstrates both modes. You should change the navigation mode to see the two modes.

List mode

Adding a list is very simple. You set the NavigationMode:
bar.NavigationMode = bar.NAVIGATION_MODE_LIST
Add the items:
bar.SetListItems(Array As String("Dropdown 1", "Dropdown 2", "Dropdown 3"))

And handle the event:
Sub bar_ListItemSelected (Index As Int, Value As String)
   Log("Selected value: " & Value)
End Sub

Tabs mode

Unlike TabHost, the tabs do not hold any views. You are responsible for switching the layout based on the selected tab.

The first step is to set the navigation mode:
bar.NavigationMode = bar.NAVIGATION_MODE_TABS

Then we add the tabs:
bar.AddTab("Tab 1")
bar.AddTab returns a StdTab object. We can use it to modify the tabs:
bar.AddTab("Tab 1").Tag = panel1
bar.AddTab("Tab 2").Tag = panel2
'Add icon to tab 3
Dim tb As StdTab = bar.AddTab("Tab 3")
tb.Tag = panel3
Dim bd As BitmapDrawable
bd.Initialize(LoadBitmap(File.DirAssets, "ic_small.png"))
tb.Icon = bd
In the above code we add three tabs and use the tabs tag property to store a panel in each tab. Later we will use these panels to switch the layout.

When the TabChanged event is raised we clear the current layout and show the new layout.
Sub bar_TabChanged(Index As Int, STab As StdTab)
   Dim pnl As Panel = STab.Tag
   Dim height As Int
   If 100%y > 100%x Then
     height = 100%y - 48dip 'fix for the additional tabs height
     height = 100%y
   End If
   Activity.AddView(pnl, 0, 0, 100%x, height)
   If pnl.NumberOfViews = 0 Then
   End If
End Sub

Note that the attached example uses the Holo.Light theme. This is done with this manifest editor line:
SetApplicationAttribute(android:theme, "@android:style/Theme.Holo.Light")

V1.52 is released. Fixes an incompatibility with Android 5.0. Note that the ButtonClicked event will not work on these devices.

You should use Activity_ActionBarHomeClick event instead.


  • StdActionBarExample.zip
    11 KB · Views: 1,525
  • StdActionBar.zip
    22.9 KB · Views: 306
Last edited:

Roberto P.

Well-Known Member
Licensed User
it works! also with Android 4.x
thanks Erel


Licensed User
Hi All

How to use StdActionBar when FullScreen mode: True and IncludeTitle: False ?

------------------- start code --------------------
Dim height As Int = CalculateHeight(True, True)
vp.Initialize("vp", 3, 100%x, height)
Activity.AddView(vp.AsView, 0, 0, 100%x, height)
'load the pages layouts
'bar.Icon = LoadBitmap(File.DirAssets, "ic_action_user.png")

bar.NavigationMode = bar.NAVIGATION_MODE_TABS

bar.AddTab("Tab 1")
bar.AddTab("Tab 2")
bar.AddTab("Tab 3")
bar.ShowUpIndicator = True
bar.SelectedIndex = currentPage
Activity.Title = "This is the title"
bar.Subtitle = "This is the subtitle"
Activity.AddMenuItem3("", "mnuEdit", LoadBitmap(File.DirAssets, "ic_action_edit.png"), True)
Activity.AddMenuItem3("", "mnuNew", LoadBitmap(File.DirAssets, "ic_action_new.png"), True)
Activity.AddMenuItem3("", "mnuUndo", LoadBitmap(File.DirAssets, "ic_action_undo.png"), True)

------------------------- end code -------------------------

In this mode, after starting the application ends java.lang.NullPointerException error ... (red text)

Thanks for advice
Last edited:


Active Member
Licensed User
Is it possible to make the tab indicator bar slide as you swipe? A good example of this would be in the Google play store app.


Licensed User
Where to put the button_click code on this sample screenshot? Do I need to make new module for that loaded layout in tab3? Please enlighten me :D

I think I need a conversion of this code:

Sub loadModuleChild_Click
End Sub

Sub Activity_Create()
End Sub

Sub Button_Click
End Sub



Well-Known Member
Licensed User
hi, Erel,,,, I do not find this library even on sdk manager, there is no link :-(


Well-Known Member
Licensed User
In SDK Manager check the node "Extras", the item "Android Support Library" must be installed. If not set the checkmark and push the install button.
If you put the mouse over the text "Android Support Library" then the path to the support libraries will be shown as hint. You find "android-support-v4.jar" in the subdir "v4" of this path. Copy this file to your additional libraries folder.

Bryanne Vega

Licensed User
I can't seem to find a way to disable a menu button while im at a specific tab (or atleast change it's visibility status).