How to implement context menu on key press instead of long click/tap

前端 未结 2 497
梦如初夏
梦如初夏 2020-12-16 03:18

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

2条回答
  •  没有蜡笔的小新
    2020-12-16 03:49

    To open the context menu, call openContextMenu(). To trigger it via a key, override onKeyDown() or onKeyUp().

    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.

提交回复
热议问题