Using SearchView
Now that PhotoRepository 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 app bar. (See Chapter 15 for detailed steps on adding the menu XML file if you need a reminder.)
Listing 21.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, 5th 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.