0

I want to add a button for settings to the options menu of my app. Do I have to do this for each Activity or can I set it globally once?

Quentamia
  • 3,244
  • 3
  • 33
  • 42

2 Answers2

2

you can extend from Activity , put there your logic of the menu , and make all of your activities extend from the new class .

android developer
  • 114,585
  • 152
  • 739
  • 1,270
1

You can @Override

public boolean onCreateOptionsMenu(Menu menu) {
menu= Aclass.options(menu);
return(super.onCreateOptionsMenu(menu));

}

in each activity, where Aclass.options(menu) a static returning method to add common options to the menu. Or, you can

Here is a good solution if you have dozens of Activities

Community
  • 1
  • 1
hoshiKuzu
  • 866
  • 1
  • 12
  • 30