How to implement custom drop-down menu to actionba

2019-06-24 22:55发布

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.

enter image description here

1条回答
虎瘦雄心在
2楼-- · 2019-06-24 23:29

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.

查看更多
登录 后发表回答