How to create a custom Pulldown in the Honeycomb ActionBar?

。_饼干妹妹 提交于 2019-12-10 17:34:55

问题


I would like to add a custom pulldown menu to the actionbar in my project similar to the one that can be found in the google books app (screen). In this case it represents the complete table of contents of the book.

I tried to follow the guide from the developer site where there is an example with a SpinnerAdapter. But when i use a custom Layout (in my case a RelativeLayout with two TextViews in it) i get an Exception that saying "ArrayAdapter requires the resource ID to be a TextView". So i dismissed my idea with the pulldown but then i found the pulldown in the books app wich looks to me like they used a custom layout as well because it looks to me like two single TextViews in one Layout.

Could anybody please enlighten me if what i want to do is even possible and how?


回答1:


To me, that looks like the options menu -- that's where options menu items not promoted to the action bar itself appear. Use onCreateOptionsMenu() and add whatever items you want to the Menu.


EDIT:

Sorry, the screenshot was a bit confusing. There are two possibilities that I can see:

  • This could be a submenu for that action bar item -- I haven't played with submenus and the action bar yet (though this reminds me that I need to do that...)
  • This could be a PopupMenu tied to a custom action bar View


来源:https://stackoverflow.com/questions/5312631/how-to-create-a-custom-pulldown-in-the-honeycomb-actionbar

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