How to implement custom drop-down menu to actionbar in android

☆樱花仙子☆ 提交于 2019-12-10 16:48:58

问题


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.

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.


回答1:


Regarding the action bar's structure, you have two options for the left side and one for the right side.

Left side:

Enable Action bar drop-down navigation

 actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_LIST);

or

Add a custom View as navigational element via ActionBar#setCustomView(), a Spinner in your case.

Right side:

Add only one MenuItem to the action bar as a custom Action View, a Spinner in your case.



来源:https://stackoverflow.com/questions/15116271/how-to-implement-custom-drop-down-menu-to-actionbar-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!