You can create a menu through code or you can create it through an XML file that is provided in the res/menu directory. The preferred method of creating menus is to define menus through XML and then inflate them into a programmable object with which you can interact. (Inflate here refers to the Android process of turning an XML file into a Java object.) This helps separate the menu definition from the actual application code.
To define an XML menu, follow these steps:
<?xml version=“1.0” encoding=“utf-8”?> <menu xmlns:android=“http://schemas.android.com/apk/res/android”> <item android:id=“@+id/menu_insert” android:icon=“@android:drawable/ic_menu_add” →4 android:title=“@string/menu_insert” /> →5 </menu>
Notice that a new string resource is included in line 5. You need to create that (which you do in Step 4). The android:icon value in line 4 is a built-in Android icon. You do not have to provide this bitmap in your drawable resources. The ldpi, mdpi, and hdpi versions of this icon are all built into the Android platform. To view other resources available to you, view the android.R.drawable documentation here: http://developer.android.com/reference/android/R.drawable.html.
All resources in the android.R class are available ...