微调器项目的上下文菜单 [英] Context menu for spinner item

查看:69
本文介绍了微调器项目的上下文菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何将上下文菜单添加到微调器弹出窗口中?

How would I go about adding a context menu to a spinner popup?

我有一个由数据库游标填充的微调器,并且我想有一个上下文菜单,因此当用户长按一个项目时,他们可以编辑或删除该项目(上下文菜单中的两个选项)。

I have a spinner that is populated by a database cursor, and I'd like to have a context menu so when the user long clicks an item they can edit or delete the item (two options in context menu).

我似乎找不到为包含可选项目的窗口注册上下文菜单的方法。有没有办法像在列表视图上一样?

I can't seem to find a way to register a context menu for the window that appears with the selectable items. Is there a way to, like on a list View?

否则,拥有一个为上下文菜单注册的隐藏视图,然后使用微调器的OnItemLongClickListener调用openContextMenu怎么办?隐藏的视图?似乎有点像hack,所以我宁愿以正确的方式来做。

Otherwise, what about having a hidden view that is registered for a context menu and then use the spinner's OnItemLongClickListener call openContextMenu for the hidden view? This seems kind of like a hack so I'd rather do it the correct way, if possible.

或者也许我应该为上下文菜单注册微调器,而不是

Or maybe I should just register the spinner for the context menu instead of having a hidden one...

谢谢!

推荐答案


如何将上下文菜单添加到微调框弹出窗口中?

How would I go about adding a context menu to a spinner popup?

理想情况下,您甚至都不会尝试。至少对于平板电脑而言,经典的弹出式上下文菜单将在新的Honeycomb UI中过时,因此,我不会花费大量时间将它们黑客化为通常不使用它们的小部件。

Ideally, you wouldn't even try. Classic pop-up context menus are going to be obsolete with the new Honeycomb UI, at least for the tablet form factor, so I would not invest a ton of time in hacking them into widgets where they aren't normally used.

此外,用户不太可能发现您的上下文菜单,仅仅是因为他们一开始往往不会太频繁地发现上下文菜单。用户往往不会尝试通过随机刺入屏幕超过一秒钟来查看菜单是否弹出。他们了解您的上下文菜单的唯一方法是阅读精美的手册,我们都知道这种情况发生的频率。因此,您需要用户采取其他方式来执行相同的操作-让他们能够通过不可发现的上下文菜单编辑/删除仅 是非常有害于用户的。因此,上下文菜单充其量是一种促进剂,不值得强加到意想不到和不受支持的地方。

Moreover, users are unlikely to discover your context menu, simply because they tend not to discover context menus too often in the first place. Users tend not to experiment by randomly stabbing the screen for a second-plus to see if menus happen to pop up. The only way they will know about your context menu is if they read the fine manual, and we all know how often that happens. Hence, you need some other way for the user to do the same operations -- having them be able to edit/delete only through a non-discoverable context menu is very user-hostile. Hence, context menus are, at best, an accelerant, and not worth forcing into unexpected and unsupported places.


我有一个旋转器我想有一个上下文菜单,因此我希望有一个上下文菜单,以便当用户长按一个项目时,他们可以编辑或删除该项目(上下文菜单中的两个选项)。

I have a spinner that is populated by a database cursor, and I'd like to have a context menu so when the user long clicks an item they can edit or delete the item (two options in context menu).

如果要使用上下文菜单,请将 Spinner 转换为 ListView 。不仅会逐渐变得更容易发现(某些用户如果长按列表项会习惯一些有趣的事情),而且上下文菜单也很自然。

If you want the context menu, convert the Spinner into a ListView. Not only will this be incrementally more discoverable (some users will be used to interesting things if they long-tap on a list item), but context menus work naturally.

如果您真正想要的是,可以将 Spinner (可能还有 AbsSpinner 或其他超类)克隆到项目中,以便进行控制下拉菜单的行为,然后在选择对话框中编写启用上下文菜单的内容。然后,您需要记住,在Android 3.0中使用新的 Spinner 的情况下,最有可能的方法就是无效,这仅仅是因为没有更多选择对话框。

If you really want, you can clone Spinner (and possibly AbsSpinner or other superclasses) into your project, so you can take control over the drop-down behavior, then write something that enables a context menu on the selection dialog box. Then, you will need to bear in mind that none of that will work, most likely, with the new Spinner in Android 3.0, simply because there is no more selection dialog box.

这篇关于微调器项目的上下文菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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