O'Reilly logo

Android 5 Programming by Example by Kyle Mew

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding menus and toolbars

Nearly all mobile apps contain some form of global menu that provides access to functions required throughout the app. Menus can be opened in several ways on Android apps, but most commonly used is the Options menu which is accessed from the toolbar or action bar. Options menu items can also appear on the toolbar, as text or graphically.

First, we will add a basic drop-down toolbar menu to implement the functions currently provided by the two buttons. Open the project from the Fragments section and follow these steps:

  1. Open the res/menu/menu_main.xml file.
  2. Replace the existing <item> tag with these three:
    <item android:id="@+id/menu_date" android:orderInCategory="100" android:showAsAction="never" android:title="Date and Time" ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required