通过短按按钮打开类似上下文菜单的菜单的最佳实践是什么?
我有一个显示“排序”的按钮,当用户正常/短按该按钮时,我希望出现一个包含各种排序选项的菜单。在网上浏览一下,似乎没有直接回答哪种路线被认为是最佳实践。我希望有一个与此类似的菜单:
带有图标和文本。
例如,单击 Google 地图应用程序中的“图层”按钮。只需单击一下即可打开选项列表。它的顶部有一个标题,每个选项都有图标。 (图标并不是非常重要)
我应该使用上下文菜单吗?如果是这样,我该如何在不长按的情况下做到这一点。它应该是一个旋转器吗?如果是这样,我如何更改外观以使用按钮而不是正常的下拉框。
I have a button that says "Sort" and when a user normal/short presses the button, I want a menu to appear with the various sort options. Looking around online there doesn't seem to be a straight forward answer to which route is considered best practice. I'm looking to have a menu that looks similar to this:
with icons and text.
For an example, click the Layers button in the Google Maps app. It opens a list of options on a single short click. It has a title at the top and icons for each option. (The icons aren't super crucial)
Should I use a Context Menu? If so, how do I do it without a long press. Should it be a Spinner? If so how do I change the appearance to use a button instead of the normal drop down box.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Spinner 用于状态选择,这听起来就像您想要的那样。用户将从列表中选择一个排序选项,并且存在对用户保持可见的“当前”排序的概念。
对于屏幕截图中的活动选择器之类的内容,Falmarri 对 AlertDialog 的建议是合理的。选择排序和活动选择器之间的区别在于“状态选择”的区别。旋转器具有已为您提供的当前选定项目的概念,对话框更通用。
Spinners are for stateful selection, which sounds like what you want here. The user will select one sort option from a list, and there is a concept of a "current" sort that stays visible to the user.
For something like the activity picker in your screenshot, Falmarri's suggestion of an AlertDialog is reasonable. The difference between choosing a sort and the activity picker is the "stateful selection" distinction. Spinners have a concept of a currently selected item already provided for you, dialogs are more general.
http://developer.android.com/reference/android/app/AlertDialog.html
http://developer.android.com/reference/android/app/AlertDialog.html