In Android application, menus are the common user interface components which gives user a dynamic user experience. The other details about menus are:
- android.view.Menu is class which provides the functionality of menu.
- Till the Android version 2.3 , dedicated menu hardware button is provided for the menu option.
- After Android version 3.0 and higher, no dedicated button is provided but instead another ways are provided according to type of menu to access the menu.
- There are three types of Menus or action used in all version of menus.
Lets learn how to create context menu in in Android application.
- First start your eclipse and select new -> project and click next.
- Now fill with following details:
- Project name- ContextMenu
- Application name-ContextMenu
- package name-context.menu
- Minimum required SDK- select android 3.0
- tick on create custom laucher icon.
- Name the activity -Context_menu
- tick on create project in workspace.
- Now after doing this open the context_menu.xml you will see the following code.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".Context_menu" />
</RelativeLayout>