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

The Search Dialog

In this section, you will implement Android’s search interface in PhotoGallery. You will start with the old style dialog interface.

Creating a search interface

In Honeycomb, the Android folks got rid of hardware search buttons. Even before that, though, there was no guarantee of having a search button. Modern Android apps that rely on search must always have a search button somewhere in the app if they are targeting pre-3.0 devices.

Implementing this is not difficult. Simply call Activity.onSearchRequested(). This method performs the exact same operation as pressing the search button.

Add a menu XML file for PhotoGallery in res/menu/fragment_photo_gallery.xml. Your app will also need an interface to clear the search query, ...

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