1. Create a menu directory in the res directory.
2. Add a file named of mymenu.xml to the menu directory. An item named myItem is created. An icon named ic_menu_add is used, from the default Android platform icons, with a visible text of "My Item"
<?xml version="1.0" encoding="utf-8"?>
<menu
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:id="@+id/myItem"
android:icon="@android:drawable/ic_menu_add"
android:title="My Item" />
</menu>
3. Compile and run!
4. For more items, you can add more items under the first item, befor the </menu> tag, to the above code. Such as,
<item android:id="@+id/myItem2"
android:icon="@android:drawable/ic_menu_delete"
android:title="My Item 2" />
Next Recommended Article: onCreateOptionsMenu - Create an Options Menu
Resources:
Popular Posts
- Solution: error: Error parsing XML: unbound prefix
- android:background - Change the Background Color of an EditText
- android:requiresFadingEdge
- Cursor getColumnIndexOrThrow - Get the Index for a Column Name
- android:maxWidth - Set the Maximum Width of TextView
- Solution: Running Android Lint has encountered a problem Failed
- How to Register an Activity that Responds to NFC tags for URI's that point to a URL
- How to Install an SDK package
- Change the line spacing between lines of text in an TextView/EditText, using lineSpacingExtra
- How to Add a Toast