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="http://schemas.android.com/apk/res/android"
      xmlns:app="http://schemas.android.com/apk/res-auto"> ...

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

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.