Searchview provides a search box that listens to user input, and when a user submits a search, it can also perform actual actions through the listener.
Common XML attributes and related methods:
XML properties |
Related methods |
Description |
Android:iconifiedbydefault |
Seticonifiedbydefault (Boolean) |
Sets whether the search box automatically shrinks to an icon |
|
Setsubmitbuttonenable (Boolean) |
Set whether the Search button is displayed |
Android:inputtype |
Setinputtype (int) |
Formatting input text |
Android:maxwidth |
Setmaxwidth (int) |
Set Maximum width |
Android:queryhint |
Setqueryhint (charsequence) |
Set Prompt text |
You can use the setonquerytextlistener () method to bind the search box to listen for events.
You can use the setquerytextsubmit () method to bind the search button to listen for events.
You can add a ListViewfor Searchview, providing it with auto-complete functionality.
Android Learning Note (29): Search box Searchview