How to create custom Pulldown in Honeycomb ActionBar?

screenshot from the google books app

I would like to add a custom drop-down menu to the action bar in my project, similar to the one found in the Google Book application (screen). In this case, it is the full table of contents of the book.

I tried to follow the guide from the developer's site, where there is an example with the SpinnerAdapter . But when I use a custom layout (in my case, RelativeLayout with two TextViews in it), I get an exception saying that "ArrayAdapter requires the resource identifier to be TextView". So I dismissed my idea with a drop-down list, but then I found a drop-down box in the book application that looks to me as if they used their own layout, because it looks like two separate text elements in one layout.

Can someone please enlighten me if what I want to do is even possible?

+4
source share
1 answer

For me, it looks like an options menu - where options menu items appear that don't appear in the action bar. Use onCreateOptionsMenu() and add all the elements you want in the Menu .


EDIT:

Sorry, the screenshot was a bit confusing. I see two possibilities:

  • This may be a submenu for this action bar item. I have not played with the submenu and action bar yet (although this reminds me that I need to do this ...)
  • This can be PopupMenu tied to a custom actions pane View
+3
source

Source: https://habr.com/ru/post/1343773/


All Articles