I want to have an options menu that is available to all Activities in my app (on pressing the MENU button). I've been doing this by creating it in onCreateOptionsMenu(Menu menu) for each Activity but this seems redundant.
Is there a way to create it in one place and have it available in all Activities?
Android Options Menu is a primary collection of menu items in an android application and is useful for actions that have a global impact on the searching application.
The options menu is the primary collection of menu items for an activity. It's where you should place actions that have a global impact on the app, such as "Search," "Compose email," and "Settings." See the section about Creating an Options Menu.
It is created automatically inside the res/menu directory.
Subclass Activity
to have your own activity class, and extend
that to inherit some functionality like OptionsMenu.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With