Adding alphabetical shortcut to the menu item in Android

There is a way to add alphabetical shortcut to your menu item.
I am going to show how it can be done.

@Override
public boolean onCreateOptionsMenu(Menu menu) {
	menu.add(0, NEW_MENU_ITEM, 0, "New").setAlphabeticShortcut('N');
...
	return super.onCreateOptionsMenu(menu);
}

As you can see it is very easy.

How you can test it? Run your code with this snippet, click Menu button and after click “N”.

  • Share/Bookmark

Related posts:

  1. Adding icon to the menu item in Android
  2. Handling Options Menu item selections in Android
  3. Creating Options Menu and adding menu items to the Options Menu in Android
  4. Using Submenu in Android
  5. Using Context Menus in Android

Leave a Reply

 

 

 

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>