Controlling Your Alarm

Now that you can turn your alarm on and off (as well as tell whether it is on or off), let’s add an interface to turn this thing on and off. Add another menu item to menu/fragment_photo_gallery.xml.

Listing 29.11  Add service toggle (menu/fragment_photo_gallery.xml)

<menu xmlns:android="http://schemas.android.com/apk/res/android">
  <item android:id="@+id/menu_item_search"
    android:title="@string/search"
    android:icon="@android:drawable/ic_menu_search"
    android:showAsAction="ifRoom"
    android:actionViewClass="android.widget.SearchView"
    />
  <item android:id="@+id/menu_item_clear"
    android:title="@string/clear_search"
    android:icon="@android:drawable/ic_menu_close_clear_cancel"
    android:showAsAction="ifRoom"
    />
  <item android:id="@+id/menu_item_toggle_polling" ...

Get Android Programming: The Big Nerd Ranch Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.