Geeks With Blogs
Bill Osuch - Random geek notes

Say you have an Android app with multiple activities (or "screens", if you prefer...) and you want to have the same options menu appear on every activity.

Simply create another activity that implements the onCreateOptionsMenu() and onOptionsItemSelected() methods, like this:

public class MasterActivity extends Activity {

   public boolean onCreateOptionsMenu(Menu menu) {  
      ... whatever ...
   public boolean onOptionsItemSelected(MenuItem item) {  
      ... whatever ...

Then have all of your other classes (activities) extend your MasterActivity class:

public class MyClass extends MasterActivity {

Posted on Wednesday, December 1, 2010 3:26 PM Android | Back to top

Comments on this post: Android - Sharing an options menu between activities

# re: Android - Sharing an options menu between activities
Requesting Gravatar...
Awesome, good logic it really helps...
Left by Shripad Bhat on Oct 26, 2011 12:32 PM

Your comment:
 (will show your gravatar)

Copyright © Bill Osuch | Powered by: