O'Reilly logo

Android Development Tools for Eclipse by Sanjay Shah, Khirulnizam Abd Rahman

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 a menu

We will invoke the Preference screen from the menu. There are essentially three different types of menus available: Options menu, Context menu, and Pop up Menu. Here, we will use the Options menu for our purpose. To add the menu under res/menu create a new file named prefsetting.xml. Add the menu item, using the <item></item> element by adding the following code:

<menu xmlns:android="http://schemas.android.com/apk/res/android"
    <item android:id="@+id/menusettings"
        android:showAsAction="never"
        android:title="Preferences"
        android:orderInCategory="100">  
    </item>
</menu>

The name of the menu item is set as android:title="Preferences". The android:showAsAction keyword indicates how an item should appear in the action bar. For more menu options ...

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