@@ -186,7 +186,12 @@ searchView.setOnMenuItemClickListener(
186
186
});
187
187
```
188
188
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
190
195
the ` SearchBar ` , as well as hide the ` SearchView ` when the user finishes typing
191
196
and presses enter:
192
197
@@ -317,6 +322,27 @@ Additionally, with this pattern it is common to hide the back button to reduce
317
322
clutter, as navigation can be handled outside of the search view. This can be
318
323
accomplished by setting ` app:hideNavigationIcon="true" ` on your ` SearchView ` .
319
324
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
+
320
346
## Putting it all together
321
347
322
348
Putting 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
350
376
android : layout_height =" match_parent"
351
377
android : hint =" @string/searchbar_hint"
352
378
app : layout_anchor =" @id/search_bar" >
379
+
353
380
<!-- Search suggestions/results go here (ScrollView, RecyclerView, etc.). -->
381
+
354
382
</com .google.android.material.search.SearchView>
355
383
</androidx .coordinatorlayout.widget.CoordinatorLayout>
356
384
```
0 commit comments