如何在android中实现自定义下拉菜单到actionbar [英] How to implement custom drop-down menu to actionbar in android
问题描述
我正在尝试在actionbar中实现下拉菜单(项目的计数可能在运行时非常)。例如:Google地图有一个。
i am trying to implement drop down menus in in actionbar, ( the count of items may very in runtime). for eg: Google map has the one.
如何在android中实现它。这里是我正在寻找的菜单。即如果我点击R图像按钮,我想要一个下拉菜单。同样地,如果我点击L,左侧菜单应该来。任何想法怎么办?
how to implement it in android. here how the menu i'm looking for. i.e if i click on R image button i want a a drop down menu. similarly if i tap on L, left side menu should come. any idea how to do? .
我不想滑动,我想要一个下拉菜单。
I dont want sliding at all, i want a dropdown menu.
推荐答案
关于操作栏的结构,左侧有两个选项,右侧有两个选项。
Regarding the action bar's structure, you have two options for the left side and one for the right side.
启用操作栏下拉导航
actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);
或
通过查看作为导航元素http://developer.android.com/reference/android/app/ActionBar.html#setCustomView% 28int%29rel =nofollow> ActionBar#setCustomView()
,一个 Spinner
案件。
Add a custom View
as navigational element via ActionBar#setCustomView()
, a Spinner
in your case.
只添加一个 MenuItem
作为自定义操作视图的操作栏, Spinner
在你的情况下。
Add only one MenuItem
to the action bar as a custom Action View, a Spinner
in your case.
这篇关于如何在android中实现自定义下拉菜单到actionbar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!