Create a settings menu available for all actions in the application

I want to have an options menu available to all actions in my application (when you press the MENU button). I did this by creating it in onCreateOptionsMenu (menu menu) for each operation, but that seems redundant.

Is there a way to create it in one place and have it in all actions?

+6
android
source share
3 answers

A subclass of Activity to have its own activity class and extend to inherit some functions, such as OptionsMenu.

+7
source share

If your other class extends the action, modify it to extend the new OptionsMenuActivity class that you created. However, if it extends one of the Activity subclasses, such as ListActivity, MapActivity, etc., then I assume that either you can either expand each of these subclasses using the options menu functions, or simply repeat the parameter menu code for each action .

0
source share

I also tried to figure it out. Like everyone else, I extend the Activity in the BaseActivity class.

The annoyance with this is when your activity extends ListActivity or some other activity class, then you also need to extend all these other activity classes.

There is Java technology that I don’t quite remember the name, but something similar to the C # define operator, which allows you to enter code.

0
source share

All Articles