MenuProvider

Added in 1.7.0

interface MenuProvider


Interface for indicating that a component will be supplying MenuItems to the component owning the app bar.

Summary

Public functions

Unit
onCreateMenu(menu: Menu, menuInflater: MenuInflater)

Called by the MenuHost to allow the MenuProvider to inflate MenuItems into the menu.

Unit

Called by the MenuHost when the Menu is closed.

Boolean

Called by the MenuHost when a MenuItem is selected from the menu.

Unit

Called by the MenuHost right before the Menu is shown.

Public functions

onCreateMenu

Added in 1.7.0
fun onCreateMenu(menu: Menu, menuInflater: MenuInflater): Unit

Called by the MenuHost to allow the MenuProvider to inflate MenuItems into the menu.

Parameters
menu: Menu

the menu to inflate the new menu items into

menuInflater: MenuInflater

the inflater to be used to inflate the updated menu

onMenuClosed

Added in 1.8.0
fun onMenuClosed(menu: Menu): Unit

Called by the MenuHost when the Menu is closed.

Parameters
menu: Menu

the menu that was closed

onMenuItemSelected

Added in 1.7.0
fun onMenuItemSelected(menuItem: MenuItem): Boolean

Called by the MenuHost when a MenuItem is selected from the menu.

Parameters
menuItem: MenuItem

the menu item that was selected

Returns
Boolean

true if the given menu item is handled by this menu provider, false otherwise

onPrepareMenu

Added in 1.8.0
fun onPrepareMenu(menu: Menu): Unit

Called by the MenuHost right before the Menu is shown. This should be called when the menu has been dynamically updated.

Parameters
menu: Menu

the menu that is to be prepared

See also
onCreateMenu