如何实现对关键preSS,而不是长按/自来水上下文菜单 [英] How to implement context menu on key press instead of long click/tap

查看:216
本文介绍了如何实现对关键preSS,而不是长按/自来水上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个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).

推荐答案

要打开上下文菜单,叫<一href="http://developer.android.com/reference/android/app/Activity.html#openContextMenu%28android.view.View%29"><$c$c>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.

这篇关于如何实现对关键preSS,而不是长按/自来水上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆