I开发者_C百科 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?
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 barView
精彩评论