Monday, 4 April 2011

Android Menus - hidden but vital

The menu is the part of the application which is hidden but it is vital to set the preferences and other options.

There are two types of menus:
  • Contextual Menu: You see it press on the screen and hold it for a while
  • Option Menu: You see it when you press on the "Menu" button.
There are two ways to "draw" the menu on the screen: Hard coding the java file or using an XML files.

Once the menu is created, the java code should handle the actions. No matter which method is used to draw the menus, the methods to capture and assign the behaviour of the menu are the same.

Personally I found the second method more clear. It separates the handler part of the display part.

Since I found good tutorial about it, I won't write too much.

Tutorials:
DroidNova: http://www.droidnova.com/how-to-create-an-option-menu,427.html (Easy and simple. XML way)
DeveloperLife: http://developerlife.com/tutorials/?p=304 (Complete but complicated, Java way)

For more information:
Official Developer guide: http://developer.android.com/reference/android/view/Menu.html
Official Developer design guidelines: http://developer.android.com/guide/practices/ui_guidelines/menu_design.html

No comments:

Post a Comment