I have a ListActivity and I want to implement context menu for each of the list elements. I know that the common way to do this is to show the context menu on long click/tap. I want to know if there is a way to show the context menu for each element on a key press(preferably the menu key).
To rephrase my question, how can I trigger the context menu and not the options menu by pressing the menu key(or any other key).
I have a ListActivity and I want to implement context menu for each of
Share
To open the context menu, call
openContextMenu(). To trigger it via a key, overrideonKeyDown()oronKeyUp().That being said, I really do not recommend this.
Users complain that Android has no UI standards. Instead, Android has UI conventions, ones that allow developers some freedom (and, more importantly, are not barriers to getting your app listed on the Android Market).
However, those users’ point is very valid — their experience is marred when apps decide to go off on a UI tangent. Deciding to have the MENU key pop a context menu would be one such tangent. For starters, on touch-screen devices, this will not work very well, because there is no selected item in your
ListView, so it would be unclear to the user what the MENU pertains to.I suspect that there is a better solution for whatever problem you think you are solving this way.