@@ -186,7 +186,12 @@ searchView.setOnMenuItemClickListener(
186186 });
187187```
188188
189- Additionally, here is an example of how you can carry over the search text to
189+ Additionally, ` SearchView ` exposes its main ` EditText ` via a ` getEditText() `
190+ method, so you can use any of the traditional
191+ [ EditText APIs] ( https://developer.android.com/reference/android/widget/EditText )
192+ to configure the search field (` setText() ` , ` addTextChangedListener() ` , etc.).
193+
194+ Here is an example of how you can carry over the search text to
190195the ` SearchBar ` , as well as hide the ` SearchView ` when the user finishes typing
191196and presses enter:
192197
@@ -317,6 +322,27 @@ Additionally, with this pattern it is common to hide the back button to reduce
317322clutter, as navigation can be handled outside of the search view. This can be
318323accomplished by setting ` app:hideNavigationIcon="true" ` on your ` SearchView ` .
319324
325+ ## Search History, Suggestions, and Results
326+
327+ ` SearchView ` is a view group component, meaning you can nest content inside of
328+ it such as:
329+
330+ - Search history when the ` SearchView ` is first expanded
331+ - Search suggestions when the user is typing
332+ - Search results once the user submits the search
333+
334+ ``` xml
335+ <com .google.android.material.search.SearchView
336+ android : layout_width =" match_parent"
337+ android : layout_height =" match_parent"
338+ android : hint =" @string/searchbar_hint"
339+ app : layout_anchor =" @id/search_bar" >
340+
341+ <!-- Search suggestions/results go here (ScrollView, RecyclerView, etc.). -->
342+
343+ </com .google.android.material.search.SearchView>
344+ ```
345+
320346## Putting it all together
321347
322348Putting it all together and using the scroll-away mode, the ` SearchBar ` and
@@ -350,7 +376,9 @@ Putting it all together and using the scroll-away mode, the `SearchBar` and
350376 android : layout_height =" match_parent"
351377 android : hint =" @string/searchbar_hint"
352378 app : layout_anchor =" @id/search_bar" >
379+
353380 <!-- Search suggestions/results go here (ScrollView, RecyclerView, etc.). -->
381+
354382 </com .google.android.material.search.SearchView>
355383</androidx .coordinatorlayout.widget.CoordinatorLayout>
356384```
0 commit comments