Using SearchView on Post-Android 3.0

Now you have a search interface that works everywhere. However, it does not work in a Honeycomb-approved fashion.

Honeycomb added a new class called SearchView. SearchView is an action view – a view that may be included within the action bar. SearchView allows your entire search interface to take place within your activity’s action bar, instead of inside a dialog superimposed on your activity. That means that it has the same styling and theming as your application, which is a good and fine thing.

Using an action view is as simple as adding an android:actionViewClass attribute to your menu item tag, like so:

Listing 28.14  Add an action view to your menu (res/menu/fragment_photo_gallery.xml)

<​m​e​n​u​ ​x​m​l​n​s​:​a​n​d​r​o​i​d​=​"​h​t​t​p​:​/​/​s​c​h​e​m​a​s​.​a​n​d​r​o​i​d​.​c​o​m​/​a​p​k​/​r​e​s​/​a​n​d​r​o​i​d​"​>​ ...

Get Android Programming: The Big Nerd Ranch Guide now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.