MenuProvider

public interface MenuProvider

androidx.core.view.MenuProvider


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

Summary

Public methods

abstract void onCreateMenu(Menu menu, MenuInflater menuInflater)

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

abstract boolean onMenuItemSelected(MenuItem menuItem)

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

Public methods

onCreateMenu

public abstract void onCreateMenu (Menu menu, 
                MenuInflater menuInflater)

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

onMenuItemSelected

public abstract boolean onMenuItemSelected (MenuItem menuItem)

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