July 2011 Entries

Android: Sharing an options menu between mutiple activities tutorial

Say you've got an app that has multiple activities, and you want each activity to use the same options menu (the menu that appears when the user taps the MENU button). Rather than repeating the Inflater and ItemSelected code on each activity, just create a new activity class and have all your other activities extend it rather than Activity. To start, create an xml layout for your menu (in the res/menu directory): <menu xmlns:android="http://schem... <item android:id="@+id/new" ......