Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating an options menu that is available to all Activities in an application

Tags:

android

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?

like image 369
Emanuil Rusev Avatar asked Jun 20 '10 15:06

Emanuil Rusev


People also ask

What is option menu in mobile application development?

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.

What is the option menu?

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.

Which directory contains options menu for activity?

It is created automatically inside the res/menu directory.


1 Answers

Subclass Activity to have your own activity class, and extend that to inherit some functionality like OptionsMenu.

like image 191
Pentium10 Avatar answered Sep 22 '22 13:09

Pentium10