Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid GridView OnItemLongClick listener called after OnItemClick
    text
    copied!<p>Basically I want to show a different context menu when the user short clicks or long clicks on a cell in the grid view. The issue I have is that if the user short clicks the OnItemClick listener is called and I see the debugger reach the code that shows the context menu but rather than moving from there to onCreateContextMenu it goes to onItemLongClick. </p> <p>I have tried using a Boolean to prevent the long click code being executed which does prevent that code being executed, however even when this is done onCreateContextMenu is not called at all.</p> <p>If I remove the onItemLongClick listener the short click listener works correctly and the context menu is shown correctly.</p> <p>I know other people have asked questions similar to this but I still haven't been able to find a solution that works. If anyone can solve this or point me in the right direction please let me know, thanks in advance. Bounty will be awarded to anyone who can even point me in the right direction.</p> <p>This is a simplified version of the code for the listeners:</p> <pre><code> mTGrid.setOnItemClickListener(new OnItemClickListener() { //this listener should show the context menu for a short click on the gridview. @Override public void onItemClick(AdapterView&lt;?&gt; parent, View v, int position, long id) { mRequiredMenu = "standard"; parent.showContextMenuForChild(v); } }); mTGrid.setOnItemLongClickListener(new OnItemLongClickListener() { //this listener should show the context menu for a long click on the gridview. @Override public boolean onItemLongClick(AdapterView&lt;?&gt; parent, View v, int position, long id) { mRequiredMenu = "options"; parent.showContextMenuForChild(v); } }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload