onCreateContextMenu - Action on Long Press on ListView ListItem

onCreateContextMenu was added in API Level 1
Activity.onCreateContextMenu (ContextMenu menu, View v,ContextMenu.ContextMenuInfo menuInfo)
Called when a context menu for the view is about to be shown. Unlike onCreateOptionsMenu(Menu), this will be called every time the context menu is about to be shown and should be populated for the view (or item inside the view for AdapterView subclasses, this can be found in the menuInfo)).
It is not safe to hold onto the context menu after this method returns.
Parameters:
menu - The context menu that is being built
v - The view for which the context menu is being built
menuInfo - Extra information about the item for which the context menu should be shown. This information will vary depending on the class of v.

1. Register ListView for a Context menu

2. In MainActivity.java file, add the below to the imports section.

import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;


3. Add the below method to your MainActivity class.

@Override
public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) {
super.onCreateContextMenu(menu, v, menuInfo);
    // do something here. To test, you could 
 Add a toast
}

4. Compile and run!

Next Recommended Article:
Resources:
http://developer.android.com/reference/android/app/Activity.html#onCreateContextMenu(android.view.ContextMenu, android.view.View, android.view.ContextMenu.ContextMenuInfo)
thedevelopersinfo.wordpress.com/2009/11/06/using-context-menus-in-android/