public class ActionMenuFragment
extends Fragment
implements android.view.View.OnKeyListener, android.view.View.OnTouchListener
Constructor and Description |
---|
ActionMenuFragment() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
alwaysShowActionMenu()
Determines if the action menu is shown always or only after user
interaction.
|
protected void |
closeActionMenu(boolean animate)
Programmatically closes the action menu.
|
boolean |
dispatchKeyEvent(android.view.KeyEvent event) |
protected int |
getActionMenuGravity()
Determines the gravity of the action menu.
|
android.content.Context |
getContext() |
protected int |
getDefaultAction()
Determines the default action item that will be selected when the action
menu displays.
|
protected int |
getDefaultActionId()
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 MenuItem
|
protected void |
invalidateActionMenu()
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.
|
protected void |
onActionMenuClosed()
Called when the action menu is dismissed via a two-finger tap gesture.
|
boolean |
onActionMenuItemSelected(android.view.MenuItem item) |
void |
onCreate(android.os.Bundle savedInstanceState) |
protected boolean |
onCreateActionMenu(android.view.Menu menu)
Initialize the contents of the Activity's action menu.
|
void |
onCreateOptionsMenu(android.view.Menu menu,
android.view.MenuInflater inflater) |
boolean |
onKey(android.view.View v,
int keyCode,
android.view.KeyEvent event) |
void |
onPause() |
protected boolean |
onPrepareActionMenu(android.view.Menu menu)
Prepare the Screen's action menu to be displayed.
|
void |
onResume() |
void |
onSaveInstanceState(android.os.Bundle outState) |
boolean |
onTouch(android.view.View v,
android.view.MotionEvent event) |
protected void |
openActionMenu()
Programmatically opens the action menu.
|
protected void |
openActionMenu(boolean animate)
Programmatically opens the action menu.
|
protected void |
setCurrentMenuItem(android.view.MenuItem item,
boolean animate)
Programmatically set a specific MenuItem to be the currently selected
item.
|
protected void |
setSpeechEnabled(boolean enable)
Sets whether action menu items will automatically be registered with the speech recognition
service.
|
public void onCreate(android.os.Bundle savedInstanceState)
public void onResume()
public void onPause()
public void onSaveInstanceState(android.os.Bundle outState)
public void onCreateOptionsMenu(android.view.Menu menu, android.view.MenuInflater inflater)
public final boolean onActionMenuItemSelected(android.view.MenuItem item)
protected void setSpeechEnabled(boolean enable)
enable
- true to enable automatic speech recognition registration, false otherwiseprotected void openActionMenu()
protected void openActionMenu(boolean animate)
animate
- true to animate the menu, false to show it without animationprotected void onActionItemFocused(android.view.MenuItem item)
item
- The menu item that has focus.protected boolean onActionItemSelected(android.view.MenuItem item)
Derived classes should call through to the base class for it to perform the default menu handling.
You will need to call this super method in a derived class before checking the state of a checkable ActionMenuItem within this function. This ensures the ActionMenuItem properly animates.
item
- The menu item that was selected.onCreateActionMenu(android.view.Menu)
protected void onActionMenuClosed()
protected void invalidateActionMenu()
onCreateActionMenu(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.protected boolean onCreateActionMenu(android.view.Menu 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.
menu
- The action menu in which you place your items.onPrepareActionMenu(android.view.Menu)
,
onActionItemSelected(android.view.MenuItem)
protected boolean onPrepareActionMenu(android.view.Menu menu)
menu
- The options menu as last shown or first initialized by
onCreateActionMenu().onCreateActionMenu(android.view.Menu)
protected int getDefaultAction()
protected int getDefaultActionId()
protected boolean alwaysShowActionMenu()
protected int getActionMenuGravity()
protected void setCurrentMenuItem(android.view.MenuItem item, boolean animate)
item
- The MenuItem to selectanimate
- whether or not to animate the selection changeprotected int getMenuItemIndex(android.view.MenuItem item, boolean visibleOnly)
item
- The MenuItem to look forvisibleOnly
- if true, only the currently visible menu items
will be searchedprotected void closeActionMenu(boolean animate)
animate
- true to animate the menu, false to show it without animationpublic android.content.Context getContext()
public boolean dispatchKeyEvent(android.view.KeyEvent event)
public boolean onKey(android.view.View v, int keyCode, android.view.KeyEvent event)
onKey
in interface android.view.View.OnKeyListener
public boolean onTouch(android.view.View v, android.view.MotionEvent event)
onTouch
in interface android.view.View.OnTouchListener