In this video we will learn how to use the SearchView widget to filter a RecyclerView in real time.
For this we will add the SearchView as an item to our options menu and make it expandable with the collapseActionView attribute. This way we can display it as an icon in our app bar, which expands to an input field when we click on it.
We implement the Filterable interface into our RecyclerView Adapter and create our own Filter, where we handle the filter logic in the asynchronous performFiltering method, which publishes the search results to the publishResults method on the UI thread.
In our Activity we then connect our SearchView with the Filter by setting an OnQueryTextListener onto our SearchView and listening for the text input in onQueryTextChange.
❗ Subscribe to the channel:
⏯ Watch more tutorials:
⭐ Become a channel member for exclusive tutorials and other perks:
㊙ Help translating the videos:
💚 Support the content:
💬 Join the Discord chat:
🎧 Audiobooks and podcasts for programmers:
👶 How to get started with Android development:
📣 Follow Coding in Flow on social media: