如何在android中实现自定义下拉菜单到actionbar [英] How to implement custom drop-down menu to actionbar in android

查看:298
本文介绍了如何在android中实现自定义下拉菜单到actionbar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在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屋!

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