且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

微调器项目的上下文菜单

更新时间:2023-12-06 08:43:28


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

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.