The following is the first few sections of a chapter from The Busy Coder's Guide to Android Development, plus headings for the remaining major sections, to give you an idea about the content of the chapter.
The action bar offers a number of other features that developers can take advantage of, ones that do not necessarily fit into the other chapters. Hence, this chapter is a “catch all” for other things you may wish to do with your action bar. Note that this chapter is focused on the native action bar, not the AppCompat backport.
Understanding this chapter requires that you have read the core chapters, particularly the one on the action bar.
What happens if you want something other than a button to appear as an action bar item? Suppose you want a field instead?
Fortunately, this is supported. Otherwise, this would be a completely pointless section of the book.
You can specify
android:actionLayout on an
<item> element in a menu
will point to a reference to a layout XML resource that you want to have inflated
into the action bar instead of a toolbar button. Then, in
you can call
findMenuItem() on the
Menu to retrieve the
associated with this
<item> element, then call
getActionView() to retrieve
the root of your inflated layout. At that point, you can hook up event listeners
to the widgets in that layout, as needed.
Obviously, since the action bar is only so big, you will need to be judicious about your use of space.
The preview of this section will not appear here for a while, due to a time machine mishap.
The preview of this section was the victim of a MITM ('Martian in the middle') attack.
The preview of this section was lost due to a rupture in the space-time continuum.