edit: this example shows how to show something else, and then the fx system menu. QuickAction from https://github.com/lorensiuswlt/NewQuickAction
@Override public void onViewCreated(View view, Bundle savedInstanceState) { super.onViewCreated(view, savedInstanceState); //....... registerForContextMenu(getListView()); } @Override public void onCreateContextMenu(ContextMenu menu, View v, ContextMenuInfo menuInfo) { super.onCreateContextMenu(menu, v, menuInfo); AdapterView.AdapterContextMenuInfo amenuInfo = (AdapterView.AdapterContextMenuInfo) menuInfo; Object item = getListAdapter().getItem(amenuInfo.position); //item could be Cursor/String/YourObject it depends on Adapter //show popup fx. QuickAction from https://github.com/lorensiuswlt/NewQuickAction QuickAction qa = new QuickAction(getActivity()); qa.setAnimStyle(QuickAction.ANIM_AUTO); qa.show(amenuInfo.targetView); }
EDIT: This ansewer is not good ... why did I make this such a weird method? because eclipse intellisense did not glorify the βgoodβ setOnLongClickListener for the ListView (since the ListView has at least 2 setOnLongClickListener methods ... one from the View and the second from the AdapterView class) ... the simplest way allows your ListFragment implement AdapterView.OnItemLongClickListener , and then add the code getListView().setOnLongClickListener(this);
source share