Class ActionMenu
-
- All Implemented Interfaces:
public class ActionMenu
Bottom sheet menu showing a list of actions. The menu consists of two sections: Fixed menu items and dynamic menu items. You can set menu items by calling setMenuItems which will a list of ActionMenuItem objects independent of their ActionMenuItem.MenuItemType (you set both fixed and dynamic menu items in one call). To show the configured call show.
-
-
Field Summary
Fields Modifier and Type Field Description public List<ActionMenuItem>
menuItems
public boolean
isShowing
-
Constructor Summary
Constructors Constructor Description ActionMenu(FragmentActivity activity)
Creates a new instance and attaches it to the parent activity
.
-
Method Summary
Modifier and Type Method Description List<ActionMenuItem>
getMenuItems()
Retrieve list of action menu items. void
setMenuItems(@Nullable() List<ActionMenuItem> menuItems)
Replaces menu items with a new set. boolean
isShowing()
Check if action menu is currently visible. static Drawable
createActionMenuIcon(@NonNull() Context context, @DrawableRes() int drawableResId)
Gets icon from drawable resource styled properly so it can be used in action menu. void
onAttach(@NonNull() FragmentActivity activity)
Called when menu is attached to the activity. void
onDetach()
Called when menu is being detached from activity. void
addActionMenuListener(@NonNull() ActionMenuListener listener)
Adds new listener for action menu lifecycle and events. void
removeActionMenuListener(@NonNull() ActionMenuListener listener)
Removes a previously added listener. boolean
show()
Shows action menu. void
dismiss()
Dismiss action menu if shown. void
setTitle(@StringRes() int titleResId)
Sets text displayed in dialog title. void
setTitle(@Nullable() String dialogTitle)
Sets text displayed in dialog title. void
addMenuItem(@NonNull() ActionMenuItem menuItem)
Add menu item to action menu. void
addMenuItems(@Nullable() List<ActionMenuItem> menuItems)
Add all menu items to action menu. void
clearFixedMenuItems()
Clear all fixed menu items. void
clearStandardMenuItems()
Clear all standard menu items. void
clearMenuItems()
Clear all menu items. -
-
Constructor Detail
-
ActionMenu
ActionMenu(FragmentActivity activity)
Creates a new instance and attaches it to the parentactivity
.- Parameters:
activity
- The parent activity to which the menu will be attached.
-
-
Method Detail
-
getMenuItems
@NonNull() List<ActionMenuItem> getMenuItems()
Retrieve list of action menu items.
- Returns:
List of all menu items.
-
setMenuItems
void setMenuItems(@Nullable() List<ActionMenuItem> menuItems)
Replaces menu items with a new set.
-
isShowing
boolean isShowing()
Check if action menu is currently visible.
- Returns:
True when action menu is currently visible.
-
createActionMenuIcon
@NonNull() static Drawable createActionMenuIcon(@NonNull() Context context, @DrawableRes() int drawableResId)
Gets icon from drawable resource styled properly so it can be used in action menu.
- Parameters:
context
- The context to retrieve resource from.drawableResId
- Drawable resource representing menu icon.
-
onAttach
void onAttach(@NonNull() FragmentActivity activity)
Called when menu is attached to the activity. This is called when creating the
ActionMenu
, and when the parentactivity
has moved to the foreground.- Parameters:
activity
- The parent activity of thisActionMenu
.
-
onDetach
void onDetach()
Called when menu is being detached from activity. This means that activity is in the background or is getting destroyed.
-
addActionMenuListener
void addActionMenuListener(@NonNull() ActionMenuListener listener)
Adds new listener for action menu lifecycle and events. If the listener has already been added previously, this method will be a no-op. Adding
null
is not allowed, and will result in an exception.- Parameters:
listener
- ActionMenuListener that should be notified of action menu lifecycle and events.
-
removeActionMenuListener
void removeActionMenuListener(@NonNull() ActionMenuListener listener)
Removes a previously added listener. Upon calling this method the
listener
will no longer be notified of action menu lifecycle and events. If the listener has not been added, this method will be a no-op. Passingnull
is not allowed and will result in an exception.- Parameters:
listener
- ActionMenuListener that should be removed.
-
show
boolean show()
Shows action menu.
- Returns:
True is going to be shown.
-
dismiss
void dismiss()
Dismiss action menu if shown.
-
addMenuItem
void addMenuItem(@NonNull() ActionMenuItem menuItem)
Add menu item to action menu.
-
addMenuItems
void addMenuItems(@Nullable() List<ActionMenuItem> menuItems)
Add all menu items to action menu.
-
clearFixedMenuItems
void clearFixedMenuItems()
Clear all fixed menu items.
-
clearStandardMenuItems
void clearStandardMenuItems()
Clear all standard menu items.
-
clearMenuItems
void clearMenuItems()
Clear all menu items.
-
-
-
-