MenuHost
interface MenuHost
ComponentActivity |
Base class for activities that enables composition of higher level components. |
Toolbar |
A standard toolbar for use within application content. |
AppCompatActivity |
Base class for activities that wish to use some of the newer platform features on older Android devices. |
BaseCarAppActivity |
Core logic for CarAppLibrary Activity interaction with a host. |
CarAppActivity |
The class representing a car app activity in the main display. |
FragmentActivity |
Base class for activities that want to use the support-based |
LauncherActivity |
This class handles providing the right launcher activity when running native applications and Car App Library applications. |
PreviewActivity |
Activity used to run |
A class that allows you to host and keep track of MenuProviders that will supply android.view.MenuItems to the app bar.
| See also | |
|---|---|
MenuHostHelper |
Summary
Public functions |
|
|---|---|
Unit |
addMenuProvider(provider: MenuProvider)Adds the given |
Unit |
addMenuProvider(provider: MenuProvider, owner: LifecycleOwner)Adds the given |
Unit |
addMenuProvider(Adds the given |
Unit |
Invalidates the |
Unit |
removeMenuProvider(provider: MenuProvider)Removes the given |
Public functions
addMenuProvider
fun addMenuProvider(provider: MenuProvider): Unit
Adds the given MenuProvider to this MenuHost. If using this method, you must manually remove the provider when necessary.
| Parameters | |
|---|---|
provider: MenuProvider |
the MenuProvider to be added |
| See also | |
|---|---|
removeMenuProvider |
addMenuProvider
fun addMenuProvider(provider: MenuProvider, owner: LifecycleOwner): Unit
Adds the given MenuProvider to this MenuHost. This MenuProvider will be removed once the given LifecycleOwner receives an Lifecycle.Event.ON_DESTROY event.
| Parameters | |
|---|---|
provider: MenuProvider |
the MenuProvider to be added |
owner: LifecycleOwner |
the Lifecycle owner whose state will determine the removal of the provider |
addMenuProvider
fun addMenuProvider(
provider: MenuProvider,
owner: LifecycleOwner,
state: Lifecycle.State
): Unit
Adds the given MenuProvider to this MenuHost once the given LifecycleOwner reaches the given Lifecycle.State. This MenuProvider will be removed once the given LifecycleOwner goes down from the given Lifecycle.State.
| Parameters | |
|---|---|
provider: MenuProvider |
the MenuProvider to be added |
owner: LifecycleOwner |
the Lifecycle owner whose state will be used for automated addition/removal |
state: Lifecycle.State |
the Lifecycle.State to check for automated addition/removal |
invalidateMenu
fun invalidateMenu(): Unit
Invalidates the android.view.Menu to ensure that what is displayed matches the current internal state of the menu. This should be called whenever the state of the menu is changed, such as items being removed or disabled based on some user event.
removeMenuProvider
fun removeMenuProvider(provider: MenuProvider): Unit
Removes the given MenuProvider from this MenuHost.
| Parameters | |
|---|---|
provider: MenuProvider |
the MenuProvider to be removed |