Defining and Using Menus in XML

Create an .xml file in the res/menu folder, for example:

res/menu/editpreferences_menu.xml

and populate it with some menu definitions, something like this:
<?xml version="1.0" encoding="utf-8"?>
<menu xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/menu_done" android:title="@string/menu_done"
android:icon="@android:drawable/ic_menu_save" />
<item android:id="@+id/menu_revert" android:title="@string/menu_revert"
android:icon="@android:drawable/ic_menu_revert" />
<item android:id="@+id/menu_help" android:title="@string/menu_help"
android:icon="@android:drawable/ic_menu_help" />
</menu>

Then inflate the XML menu using the onCreateOptionsMenu in the Activity:
public class EditPreferences extends Activity {
...
@Override
public boolean onCreateOptionsMenu(Menu menu) {
super.onCreateOptionsMenu(menu);
getMenuInflater().inflate(R.menu.editpreferences_menu, menu);
return true;
}
}