This answer does not solve the question user1, but the symptoms were similar to my problem (i.e. OnItemClickListener was called, but OnItemLongClickListener not). I am posting my answer here if someone else stumbles on this question, as I did, trying to solve my problem.
I used ListView inside the fragment and implemented listener methods:
public class MyFragment extends Fragment implements OnClickListener, OnLongClickListener, OnItemClickListener, OnItemLongClickListener {
Here is the onItemClick method that worked fine:
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long rowId) { Log.i("Chimee", "short click working"); }
And here is the onItemLongClick method that did not work:
@Override public boolean onItemLongClick(AdapterView<?> parent, View view, int position, long rowId) { Log.i("Chimee", "Long click working"); return false; }
Of course, the simple answer was that I forgot the setOnItemLongClickListener . I added it after setOnItemClickListener , which I had all the time, and then it worked fine.
@Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { View v = inflater.inflate(R.layout.my_fragment, container, false); lvSuggestions = (ListView) v.findViewById(R.id.lvSuggestions); lvSuggestions.setChoiceMode(ListView.CHOICE_MODE_SINGLE); lvSuggestions.setOnItemClickListener(this); lvSuggestions.setOnItemLongClickListener(this);