Most visited

Recently visited

ActionMenuView

public class ActionMenuView
extends LinearLayoutCompat

java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.support.v7.widget.LinearLayoutCompat
         ↳ android.support.v7.widget.ActionMenuView


ActionMenuView is a presentation of a series of menu options as a View. It provides several top level options as action buttons while spilling remaining options over as items in an overflow menu. This allows applications to present packs of actions inline with specific or repeating content.

Summary

Nested classes

class ActionMenuView.LayoutParams

 

interface ActionMenuView.OnMenuItemClickListener

Interface responsible for receiving menu item click events if the items themselves do not have individual item click listeners. 

Inherited XML attributes

From class android.view.ViewGroup
From class android.view.View

Inherited constants

From class android.support.v7.widget.LinearLayoutCompat
From class android.view.ViewGroup
From class android.view.View

Inherited fields

From class android.view.View

Public constructors

ActionMenuView(Context context)
ActionMenuView(Context context, AttributeSet attrs)

Public methods

void dismissPopupMenus()

Dismiss any popups associated with this menu view.

boolean dispatchPopulateAccessibilityEvent(AccessibilityEvent event)

Dispatches an AccessibilityEvent to the View first and then to its children for adding their text content to the event.

ActionMenuView.LayoutParams generateLayoutParams(AttributeSet attrs)

Returns a new set of layout parameters based on the supplied attributes set.

Menu getMenu()

Returns the Menu object that this ActionMenuView is currently presenting.

Drawable getOverflowIcon()

Return the current drawable used as the overflow icon.

int getPopupTheme()
boolean hideOverflowMenu()

Hide the overflow items from the associated menu.

boolean isOverflowMenuShowing()

Check whether the overflow menu is currently showing.

void onConfigurationChanged(Configuration newConfig)

Called when the current configuration of the resources being used by the application have changed.

void onDetachedFromWindow()

This is called when the view is detached from a window.

void setOnMenuItemClickListener(ActionMenuView.OnMenuItemClickListener listener)
void setOverflowIcon(Drawable icon)

Set the icon to use for the overflow button.

void setPopupTheme(int resId)

Specifies the theme to use when inflating popup menus.

boolean showOverflowMenu()

Show the overflow items from the associated menu.

Protected methods

boolean checkLayoutParams(ViewGroup.LayoutParams p)
ActionMenuView.LayoutParams generateDefaultLayoutParams()

Returns a set of layout parameters with a width of MATCH_PARENT and a height of WRAP_CONTENT when the layout's orientation is VERTICAL.

ActionMenuView.LayoutParams generateLayoutParams(ViewGroup.LayoutParams p)

Returns a safe set of layout parameters based on the supplied layout params.

void onLayout(boolean changed, int left, int top, int right, int bottom)

Called from layout when this view should assign a size and position to each of its children.

void onMeasure(int widthMeasureSpec, int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height.

Inherited methods

From class android.support.v7.widget.LinearLayoutCompat
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.view.ViewParent
From interface android.view.ViewManager
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.accessibility.AccessibilityEventSource

Public constructors

ActionMenuView

ActionMenuView (Context context)

Parameters
context Context

ActionMenuView

ActionMenuView (Context context, 
                AttributeSet attrs)

Parameters
context Context
attrs AttributeSet

Public methods

dismissPopupMenus

void dismissPopupMenus ()

Dismiss any popups associated with this menu view.

dispatchPopulateAccessibilityEvent

boolean dispatchPopulateAccessibilityEvent (AccessibilityEvent event)

Dispatches an AccessibilityEvent to the View first and then to its children for adding their text content to the event. Note that the event text is populated in a separate dispatch path since we add to the event not only the text of the source but also the text of all its descendants. A typical implementation will call onPopulateAccessibilityEvent(AccessibilityEvent) on the this view and then call the dispatchPopulateAccessibilityEvent(AccessibilityEvent) on each child. Override this method if custom population of the event text content is required.

If an View.AccessibilityDelegate has been specified via calling setAccessibilityDelegate(AccessibilityDelegate) its dispatchPopulateAccessibilityEvent(View, AccessibilityEvent) is responsible for handling this call.

Note: Accessibility events of certain types are not dispatched for populating the event text via this method. For details refer to AccessibilityEvent.

Parameters
event AccessibilityEvent: The event.
Returns
boolean True if the event population was completed.

generateLayoutParams

ActionMenuView.LayoutParams generateLayoutParams (AttributeSet attrs)

Returns a new set of layout parameters based on the supplied attributes set.

Parameters
attrs AttributeSet: the attributes to build the layout parameters from
Returns
ActionMenuView.LayoutParams an instance of ViewGroup.LayoutParams or one of its descendants

getMenu

Menu getMenu ()

Returns the Menu object that this ActionMenuView is currently presenting.

Applications should use this method to obtain the ActionMenuView's Menu object and inflate or add content to it as necessary.

Returns
Menu the Menu presented by this view

getOverflowIcon

Drawable getOverflowIcon ()

Return the current drawable used as the overflow icon.

Returns
Drawable The overflow icon drawable

getPopupTheme

int getPopupTheme ()

Returns
int resource identifier of the theme used to inflate popup menus, or 0 if menus are inflated against the action menu view theme

See also:

hideOverflowMenu

boolean hideOverflowMenu ()

Hide the overflow items from the associated menu.

Returns
boolean true if the menu was able to be hidden, false otherwise

isOverflowMenuShowing

boolean isOverflowMenuShowing ()

Check whether the overflow menu is currently showing. This may not reflect a pending show operation in progress.

Returns
boolean true if the overflow menu is currently showing

onConfigurationChanged

void onConfigurationChanged (Configuration newConfig)

Called when the current configuration of the resources being used by the application have changed. You can use this to decide when to reload resources that can changed based on orientation and other configuration characteristics. You only need to use this if you are not relying on the normal Activity mechanism of recreating the activity instance upon a configuration change.

Parameters
newConfig Configuration: The new resource configuration.

onDetachedFromWindow

void onDetachedFromWindow ()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.

setOnMenuItemClickListener

void setOnMenuItemClickListener (ActionMenuView.OnMenuItemClickListener listener)

Parameters
listener ActionMenuView.OnMenuItemClickListener

setOverflowIcon

void setOverflowIcon (Drawable icon)

Set the icon to use for the overflow button.

Parameters
icon Drawable: Drawable to set, may be null to clear the icon

setPopupTheme

void setPopupTheme (int resId)

Specifies the theme to use when inflating popup menus. By default, uses the same theme as the action menu view itself.

Parameters
resId int: theme used to inflate popup menus

See also:

showOverflowMenu

boolean showOverflowMenu ()

Show the overflow items from the associated menu.

Returns
boolean true if the menu was able to be shown, false otherwise

Protected methods

checkLayoutParams

boolean checkLayoutParams (ViewGroup.LayoutParams p)

Parameters
p ViewGroup.LayoutParams
Returns
boolean

generateDefaultLayoutParams

ActionMenuView.LayoutParams generateDefaultLayoutParams ()

Returns a set of layout parameters with a width of MATCH_PARENT and a height of WRAP_CONTENT when the layout's orientation is VERTICAL. When the orientation is HORIZONTAL, the width is set to WRAP_CONTENT and the height to WRAP_CONTENT.

Returns
ActionMenuView.LayoutParams a set of default layout parameters or null

generateLayoutParams

ActionMenuView.LayoutParams generateLayoutParams (ViewGroup.LayoutParams p)

Returns a safe set of layout parameters based on the supplied layout params. When a ViewGroup is passed a View whose layout params do not pass the test of checkLayoutParams(android.view.ViewGroup.LayoutParams), this method is invoked. This method should return a new set of layout params suitable for this ViewGroup, possibly by copying the appropriate attributes from the specified set of layout params.

Parameters
p ViewGroup.LayoutParams: The layout parameters to convert into a suitable set of layout parameters for this ViewGroup.
Returns
ActionMenuView.LayoutParams an instance of ViewGroup.LayoutParams or one of its descendants

onLayout

void onLayout (boolean changed, 
                int left, 
                int top, 
                int right, 
                int bottom)

Called from layout when this view should assign a size and position to each of its children. Derived classes with children should override this method and call layout on each of their children.

Parameters
changed boolean: This is a new size or position for this view
left int: Left position, relative to parent
top int: Top position, relative to parent
right int: Right position, relative to parent
bottom int: Bottom position, relative to parent

onMeasure

void onMeasure (int widthMeasureSpec, 
                int heightMeasureSpec)

Measure the view and its content to determine the measured width and the measured height. This method is invoked by measure(int, int) and should be overridden by subclasses to provide accurate and efficient measurement of their contents.

CONTRACT: When overriding this method, you must call setMeasuredDimension(int, int) to store the measured width and height of this view. Failure to do so will trigger an IllegalStateException, thrown by measure(int, int). Calling the superclass' onMeasure(int, int) is a valid use.

The base class implementation of measure defaults to the background size, unless a larger size is allowed by the MeasureSpec. Subclasses should override onMeasure(int, int) to provide better measurements of their content.

If this method is overridden, it is the subclass's responsibility to make sure the measured height and width are at least the view's minimum height and width (getSuggestedMinimumHeight() and getSuggestedMinimumWidth()).

Parameters
widthMeasureSpec int: horizontal space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.
heightMeasureSpec int: vertical space requirements as imposed by the parent. The requirements are encoded with View.MeasureSpec.

Hooray!