Code example for ContextMenu

Methods: add, setHeaderTitle

0
		// Required onCreate setup 
		// add some events to the listview 
		ListView lsv = (ListView) findViewById(R.id.lsv_createfields);
		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;
			}