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 and attributes please refer to the following URLs: