Android Programming: The Big Nerd Ranch Guide, Third Edition
by Bill Phillips, Chris Stewart, Kristin Marsicano
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.
SearchView is an action view – a view that may be included within the toolbar. SearchView allows your entire search interface to live within your application’s toolbar.
First, confirm that a toolbar (containing your app title) appears at the top of your app. If not, follow the steps outlined in Chapter 13 to add a toolbar to your app.
Next, create a new menu XML file for PhotoGalleryFragment in res/menu/fragment_photo_gallery.xml. This file will specify the items that should appear in the toolbar.
Listing 27.6 Adding menu XML file (res/menu/fragment_photo_gallery.xml ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access