Using SearchView

Now that FlickrFetchr supports searching, it is time to add a way for the user to enter a query and initiate a search. Do this by adding a SearchView.

As we said at the beginning of the chapter, SearchView is an action view, meaning your entire search interface can live in your application’s app bar.

Create a new menu XML file for PhotoGalleryFragment called res/menu/fragment_photo_gallery.xml. This file will specify the items that should appear in the toolbar. (See Chapter 14 for detailed steps on adding the menu XML file, if you need a reminder.)

Listing 26.6  Adding a menu XML file (res/menu/fragment_photo_gallery.xml)

<menu xmlns:android=""
      xmlns:app=""> ...

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

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