Package com.vuzix.hud.actionmenu
Class ActionMenuView
java.lang.Object
com.vuzix.hud.actionmenu.ActionMenuView
Instance of an ActionMenu that is attached to a View
Note: An instance of an Activity is not needed at any point for this ActionMenu to function.
-
Constructor Summary
ConstructorDescriptionActionMenuView
(android.content.Context context, android.view.View parent) General constructor -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Determines if the action menu is shown always or only after user interaction.void
closeActionMenu
(boolean animate) Programmatically closes the action menu.boolean
dispatchKeyEvent
(android.view.KeyEvent event) protected int
Determines the gravity of the action menu.android.content.Context
protected int
Determines the default action item that will be selected when the action menu displays.protected int
Allows subclasses to specify the default item in the menu based on id.protected int
getMenuItemIndex
(android.view.MenuItem item, boolean visibleOnly) Retrieve the index in the menu for a specific MenuItemprotected void
Declare that the action menu has changed, so should be recreated.protected void
onActionItemFocused
(android.view.MenuItem item) This hook is called whenever the focused item in your action menu changes.protected boolean
onActionItemSelected
(android.view.MenuItem item) This hook is called whenever an item in your action menu is selected.final boolean
onActionMenuItemSelected
(android.view.MenuItem item) protected boolean
onCreateActionMenu
(android.view.Menu menu) Initialize the contents of the Activity's action menu.protected boolean
onPrepareActionMenu
(android.view.Menu menu) Prepare the Screen's action menu to be displayed.void
Programmatically opens the action menu.void
openActionMenu
(boolean animate) Programmatically opens the action menu.protected void
setCurrentMenuIndex
(int index, boolean animate) Programmatically set a specific index to be the currently selected item.protected void
setCurrentMenuItem
(android.view.MenuItem item, boolean animate) Programmatically set a specific MenuItem to be the currently selected item.
-
Constructor Details
-
ActionMenuView
public ActionMenuView(android.content.Context context, android.view.View parent) General constructor- Parameters:
context
- Contextparent
- View to which the ActionMenu will attach itself
-
-
Method Details
-
onActionMenuItemSelected
public final boolean onActionMenuItemSelected(android.view.MenuItem item) -
openActionMenu
public void openActionMenu()Programmatically opens the action menu. If the action menu is already open, this method does nothing. -
openActionMenu
public void openActionMenu(boolean animate) Programmatically opens the action menu. If the action menu is already open, this method does nothing.- Parameters:
animate
- true to animate the menu, false to show it without animation
-
onActionItemFocused
protected void onActionItemFocused(android.view.MenuItem item) This hook is called whenever the focused item in your action menu changes. The default implementation does nothing. Subclasses can override to perform logic as the focus changes.- Parameters:
item
- The menu item that has focus.
-
onActionItemSelected
protected boolean onActionItemSelected(android.view.MenuItem item) This hook is called whenever an item in your action menu is selected. The default implementation simply returns false to have the normal processing happen. You can use this method for any items for which you would like to do processing without those other facilities.Derived classes should call through to the base class for it to perform the default menu handling.
- Parameters:
item
- The menu item that was selected.- Returns:
- boolean Return false to allow normal menu processing to proceed, true to consume it here.
- See Also:
-
invalidateActionMenu
protected void invalidateActionMenu()Declare that the action menu has changed, so should be recreated. TheonCreateActionMenu(Menu)
method will be called the next time it needs to be displayed. If the action menu is currently being displayed, the menu will be rebuilt immediately. -
onCreateActionMenu
protected boolean onCreateActionMenu(android.view.Menu menu) Initialize the contents of the Activity's action menu. You should place your menu items in to menu.This is only called once, the first time the action menu is displayed. To update the menu every time it is displayed, see
onPrepareActionMenu(android.view.Menu)
.The default implementation populates the menu with a back menu item. Deriving classes should always call through to the base implementation.
You can safely hold on to menu (and any items created from it), making modifications to it as desired, until the next time onCreateOptionsMenu() is called.
When you add items to the menu, you can implement the Activity's
onActionItemSelected(android.view.MenuItem)
method to handle them there.- Parameters:
menu
- The action menu in which you place your items.- Returns:
- You must return true for the menu to be displayed; if you return false it will not be shown.
- See Also:
-
onPrepareActionMenu
protected boolean onPrepareActionMenu(android.view.Menu menu) Prepare the Screen's action menu to be displayed. This is called right before the menu is shown, every time it is shown. You can use this method to efficiently enable/disable items or otherwise dynamically modify the contents.- Parameters:
menu
- The options menu as last shown or first initialized by onCreateActionMenu().- Returns:
- You must return true for the menu to be displayed; if you return false it will not be shown.
- See Also:
-
getDefaultAction
protected int getDefaultAction()Determines the default action item that will be selected when the action menu displays. By default it is the first item in the menu. Override this method to change the behavior.- Returns:
- the index of the default menu item to select
-
getDefaultActionId
protected int getDefaultActionId()Allows subclasses to specify the default item in the menu based on id. This will be called before getDefaultAction. If this method returns a non-zero value, that will be used as the default ID, otherwise, getDefaultAction will be called as a fallback.- Returns:
- the id the default menu item to select
-
alwaysShowActionMenu
protected boolean alwaysShowActionMenu()Determines if the action menu is shown always or only after user interaction. Subclasses may override to change behavior- Returns:
- true to always show action menu, false to only show after user interaction
-
getActionMenuGravity
protected int getActionMenuGravity()Determines the gravity of the action menu. By default, the action menu appears at the bottom of the screen. Override this method to change behavior.- Returns:
- a Gravity constant
-
setCurrentMenuItem
protected void setCurrentMenuItem(android.view.MenuItem item, boolean animate) Programmatically set a specific MenuItem to be the currently selected item. If the specified item is not found or is not currently visible, nothing will change- Parameters:
item
- The MenuItem to selectanimate
- whether or not to animate the selection change
-
setCurrentMenuIndex
protected void setCurrentMenuIndex(int index, boolean animate) Programmatically set a specific index to be the currently selected item. If the specified index is not valid or the menu is not currently visible, nothing will change.- Parameters:
index
- The index of a MenuItem to selectanimate
- whether or not to animate the selection change
-
getMenuItemIndex
protected int getMenuItemIndex(android.view.MenuItem item, boolean visibleOnly) Retrieve the index in the menu for a specific MenuItem- Parameters:
item
- The MenuItem to look forvisibleOnly
- if true, only the currently visible menu items will be searched- Returns:
- The index of the specified MenuItem. If the item was not found, or visibleOnly was true, and the desired MenuItem is not currently visible, -1 will be returned.
-
closeActionMenu
public void closeActionMenu(boolean animate) Programmatically closes the action menu. If the action menu is already closed, this method does nothing. If the action menu has been specified to always be shown, this method does nothing.- Parameters:
animate
- true to animate the menu, false to show it without animation
-
getContext
public android.content.Context getContext() -
dispatchKeyEvent
public boolean dispatchKeyEvent(android.view.KeyEvent event)
-