Android Programming Press on the image to return to the main documentation page.

AHActionBar

Written by Markus Stipp

This library provides an ActionBar.

The ActionBar was introduced in Android 3.0. This is a complete custom
implementation of an ActionBar so it is not really compatible with
the Android 3.0+ ActionBar.

This library is somewhat different to other libraries because it makes use
of standard Android resource files. Resource files cannot be published inside
a .jar file and so you have to copy them to your Basic4Android project directory.

Copy the whole "res" directory structure to the "Objects" directory of your B4A
project and VERY IMPORTANT: make them READ ONLY! Otherwise B4A will delete them
when compiling. After you make any change to the Objecs/res directory use
"Clean project" menu item in B4A to force the compiler to recreate the R.java file.

If you forget to make the resource files read only then you will most likely get
a ResourceNotFound exception when you try to use the ActiionBar.

The object is highly based on an open source project by Johan Nilsson:
Android-ActionBar

List of types:

AHActionBar

AHActionBar


This is an 'Activity Object', it cannot be declared under Sub Process_Globals.

Events:

ItemClicked(ItemID As Int)

Members:


  ActionCount As Int [read only]

  ActionWidth As Int

  AddAction (ItemId As Int, Icon As android.graphics.drawable.Drawable)

  AddAction2 (ItemId As Int, Icon As android.graphics.drawable.Drawable, HelpText As CharSequence)

  AddActionAt (ItemId As Int, Icon As android.graphics.drawable.Drawable, Index As Int)

  AddActionAt2 (ItemId As Int, Icon As android.graphics.drawable.Drawable, Index As Int, HelpText As CharSequence)

  AddHomeAction (ItemId As Int, Icon As android.graphics.drawable.Drawable)

  Background As android.graphics.drawable.Drawable

  BringToFront

  Enabled As Boolean

  GetActionID (Index As Int) As Int

  GetActionView (ItemID As Int) As android.view.View

  GetActionVisibility (ItemID As Int) As Boolean

  Height As Int

  HomeAsUp As Boolean

  HomeLogo As android.graphics.drawable.Drawable [write only]

  Initialize (EventName As String)

  Initialize2 (EventName As String, Background As android.graphics.drawable.Drawable)

  Invalidate

  Invalidate2 (arg0 As android.graphics.Rect)

  Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  IsInitialized As Boolean

  Left As Int

  ProgressBarVisible As Boolean

  RemoveAction (ItemId As Int)

  RemoveActionAt (Index As Int)

  RemoveView

  SendToBack

  SetActionIcon (ItemID As Int, Icon As android.graphics.drawable.Drawable)

  SetActionPadding (ItemID As Int, Padding As Int)

  SetActionVisibility (ItemID As Int, Visible As Boolean)

  SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)

  ShowHome As Boolean

  ShowTitle As Boolean

  SubTitle As CharSequence

  Tag As Object

  Title As CharSequence

  TitleColor As Int [write only]

  Top As Int

  UseLogo As Boolean

  Visible As Boolean

  Width As Int

Members description:

ActionCount As Int [read only]
Gets the current count of actions added to the action bar
ActionWidth As Int
Set or get the action item width. The height is always the height of the action bar.
The default width is 42dip. You should set this value to the same value as your action bar height to get sqare action items.
AddAction (ItemId As Int, Icon As android.graphics.drawable.Drawable)
Add an action item at the last position.

ItemId - Id for the action item. This should be a unique id.
Icon - Drawable of an Icon
AddAction2 (ItemId As Int, Icon As android.graphics.drawable.Drawable, HelpText As CharSequence)
Add an action item at the last position.

ItemId - Id for the action item. This should be a unique id.
Icon - Drawable of an Icon
HelpText - Text to display for long click event
AddActionAt (ItemId As Int, Icon As android.graphics.drawable.Drawable, Index As Int)
Add an action item at the specified position.

ItemId - Id for the action item. This should be a unique id.
Icon - Drawable of an Icon
Index - Position of the new action item
AddActionAt2 (ItemId As Int, Icon As android.graphics.drawable.Drawable, Index As Int, HelpText As CharSequence)
Add an action item at the specified position.

ItemId - Id for the action item. This should be a unique id.
Icon - Drawable of an Icon
Index - Position of the new action item
HelpText - Text to display for long click event
AddHomeAction (ItemId As Int, Icon As android.graphics.drawable.Drawable)
Add a home action item.

ItemId - Id for the home action item. This should be a unique id.
Icon - a bitmap drawable with an icon.
Background As android.graphics.drawable.Drawable
Set or get the background drawable.
BringToFront
Enabled As Boolean
GetActionID (Index As Int) As Int
The ID of the action at the given index.

Index - index of the action item

Returns -1 if the action item does not exist.
GetActionView (ItemID As Int) As android.view.View
Returns the View that represents the action item. This is not a standard B4A View but you can pass this to the AHQuickAction popup.

ItemID - ID of the action

Returns a reference to an Android Imagebutton. Null, if the action item is not found.
GetActionVisibility (ItemID As Int) As Boolean
Get the visibility of an action item

ItemID - Id of the action item

Returns if the item is visible or not. Returns false if the item is not found.
Height As Int
HomeAsUp As Boolean
Set or get the status if home item should be displayed as "up" item.
HomeLogo As android.graphics.drawable.Drawable [write only]
Set the Home Logo
Initialize (EventName As String)
Initializes the object.

EventName - Sets the sub that will handle the event.
Initialize2 (EventName As String, Background As android.graphics.drawable.Drawable)
Initializes the object.

EventName - Sets the sub that will handle the event.
Background - A backgrounddrawable for the background of the status bar. Should be a StateListDrawable to support item pressed state.
Invalidate
Invalidate2 (arg0 As android.graphics.Rect)
Invalidate3 (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
IsInitialized As Boolean
Left As Int
ProgressBarVisible As Boolean
Set or get visibility of progress indicator
RemoveAction (ItemId As Int)
Remove the action with the specified itemID.

ItemId - Id of the action to be removed
RemoveActionAt (Index As Int)
Remove the action at the specified index.

Index - Position of the item which should be removed.
RemoveView
SendToBack
SetActionIcon (ItemID As Int, Icon As android.graphics.drawable.Drawable)
Change the Icon for an action item

ItemID - ID of the Action
Icon - New Icon
SetActionPadding (ItemID As Int, Padding As Int)
Change the padding for the icon. Useful to scale the icon.

ItemID - ID of the action for which the padding should be changed
Padding - padding value
SetActionVisibility (ItemID As Int, Visible As Boolean)
Set the visibility of an action item

ItemID - Id of the action item to make visible or invisible
Visible - Flag for status
SetLayout (arg0 As Int, arg1 As Int, arg2 As Int, arg3 As Int)
ShowHome As Boolean
Set or get Home item status
ShowTitle As Boolean
Sets or gets title status
SubTitle As CharSequence
Set or get the subtitle. If you pass Null, the subtitle is hidden.
Tag As Object
Title As CharSequence
Set or get the title of the action bar.
TitleColor As Int [write only]
Set the title and subtitle color
Top As Int
UseLogo As Boolean
Set or get property if a logo should be displayed instead of the application icon or home icon.
Visible As Boolean
Sets or gets the visible status of the ActionBar.
Width As Int

Top