Code example for ContextMenu

Methods: setHeaderTitleadd

		// Required onCreate setup 
		// add some events to the listview 
		ListView lsv = (ListView) findViewById(;
		lsv.setOnCreateContextMenuListener(new View.OnCreateContextMenuListener() {
			public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
				menu.setHeaderTitle("Current Field");
				menu.add(0, CONTEXT_MOVE_UP, 0, "Move Up");
				menu.add(0, CONTEXT_MOVE_DOWN, 0, "Move Down");
				// menu.add(0, CONTEXT_EDIT, 0, "Edit"); 
				menu.add(0, CONTEXT_REMOVE, 0, "Remove").setIcon(android.R.drawable.ic_menu_delete);
		lsv.setOnItemClickListener(new OnItemClickListener() {
			public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
				// TODO Auto-generated method stub 
				selectedFieldPosition = arg2;
Contextual code suggestions in your IDE  Get Codota for Java