如何实现对关键preSS,而不是长按/自来水上下文菜单自来、下文、水上、如何实现

由网友(三人行必有电灯泡i)分享简介:我有一个ListActivity,我想要实现的上下文菜单的每个列表中的元素。我知道,要做到这一点,常用的方法是显示在长按/自来水上下文菜单。我想知道是否有一种方式来显示上的一个键preSS(preferably菜单键)每个元素的上下文菜单。要改写我的问题,我是如何引发的上下文菜单,而不是由pressing菜单键选项菜...

我有一个ListActivity,我想要实现的上下文菜单的每个列表中的元素。我知道,要做到这一点,常用的方法是显示在长按/自来水上下文菜单。我想知道是否有一种方式来显示上的一个键preSS(preferably菜单键)每个元素的上下文菜单。 要改写我的问题,我是如何引发的上下文菜单,而不是由pressing菜单键选项菜单(或任何其它键)。

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).

推荐答案

要打开上下文菜单,叫openContextMenu().要通过一键触发它,覆盖的onkeydown()的onkeyup()

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.

用户抱怨Android有没有UI标准。相反,Android有UI惯例,那些允许开发人员一定的自由(和,更重要的是,都没有障碍,让你的应用程序列在Android Market)。

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).

不过,这些用户的点是非常有效的 - 当应用程序决定在UI上切走了他们的经验毁损。决定进行MENU键弹出快捷菜单将是一个这样的正切值。对于初学者来说,在触摸屏设备,这不太管用,因为在你的的ListView没有选择项,所以这将是不清楚用户什么MENU(菜单)涉及。

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.

阅读全文

相关推荐

最新文章