MenuHost
public 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. |
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 methods |
|
|---|---|
abstract void |
addMenuProvider(@NonNull MenuProvider provider)Adds the given |
abstract void |
addMenuProvider(Adds the given |
abstract void |
addMenuProvider(Adds the given |
abstract void |
Invalidates the |
abstract void |
removeMenuProvider(@NonNull MenuProvider provider)Removes the given |
Public methods
addMenuProvider
abstract void addMenuProvider(@NonNull MenuProvider provider)
Adds the given MenuProvider to this MenuHost. If using this method, you must manually remove the provider when necessary.
| Parameters | |
|---|---|
@NonNull MenuProvider provider |
the MenuProvider to be added |
| See also | |
|---|---|
removeMenuProvider |
addMenuProvider
abstract void addMenuProvider(
@NonNull MenuProvider provider,
@NonNull LifecycleOwner owner
)
Adds the given MenuProvider to this MenuHost. This MenuProvider will be removed once the given LifecycleOwner receives an Lifecycle.Event.ON_DESTROY event.
| Parameters | |
|---|---|
@NonNull MenuProvider provider |
the MenuProvider to be added |
@NonNull LifecycleOwner owner |
the Lifecycle owner whose state will determine the removal of the provider |
addMenuProvider
abstract void addMenuProvider(
@NonNull MenuProvider provider,
@NonNull LifecycleOwner owner,
@NonNull Lifecycle.State state
)
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 | |
|---|---|
@NonNull MenuProvider provider |
the MenuProvider to be added |
@NonNull LifecycleOwner owner |
the Lifecycle owner whose state will be used for automated addition/removal |
@NonNull Lifecycle.State state |
the Lifecycle.State to check for automated addition/removal |
invalidateMenu
abstract void invalidateMenu()
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
abstract void removeMenuProvider(@NonNull MenuProvider provider)
Removes the given MenuProvider from this MenuHost.
| Parameters | |
|---|---|
@NonNull MenuProvider provider |
the MenuProvider to be removed |