O'Reilly logo

Android Programming: The Big Nerd Ranch Guide by Brian Hardy, Bill Phillips

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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​"​>​ ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required