Filter recyclerview items in between the range of numbers in android

In Android, recyclerview is majorly used component to show the item list data into recyclerview. Showing the list of data from a database or an API is pretty easy. But I am not going into the deep concept how we are using the recyclerview to show the data from API or database. In this tutorial, I am focusing about to filter the item of recyclerview in between the range of given numbers.

In many application, mainly in product type application, we have seen to filter the item based on price in between the range is very common. So in this tutorial, we will learn how can we filter the recyclerview item in between the range. Suppose you have thousands of product items showing on recyclerview. In this case to pick any particular item from a scroll is very difficult. To make this easy we can use filter the item based on search or sort the product name in the alphabet. I would be recommended to check this post to make the recyclerview search and sort is very easy to find any product. Here is post detail Android Filter Recyclerview by using SearchView in ToolBar or action bar.

For using the recyclerview we need to add the recyclerview dependency in our build.gradle file and for filtering item in between the range I am using a third party dependency material range bar.

OK, that’s all basic required thing to filter items in between the range. I am filtering the data from a database. I used the GreenDao database to filter the item. If you do not aware of the Green DAO then I would be recommended to check this post in detail to get understand about the Green Dao fast ORM. Here is the link for Exploring GreenDAO ORM database with Reactive RxJava in Android.

Here is the uploaded the video for filter the item of recyclerview in between the range of the number of backers by using the material range bar. Please check the video to get understand what we can do with the filter?

Great, let’s see how can we do with source code. As we have seen in the video that I used the popup dialog for the filter the items in between the range of numbers by using the material range bar. I used the material dialog to provides the material kind of feeling so that our user interface will look good and attractive for users.

And here are layout_dialog XML detail.

Now I need callback when button action happen. So I used the interface for a callback.

Ok now we need to call this method to execute, but before we need to get the filtered data from the database. Here is used a query to filter.

Ok, Let’s call the method to execute the filter and update the recyclerview by using the notifyDataSetChange.

That’s it. Let’s implement the same thing in your application.

Please do subscribe your email to get every newsletter from this blog and if you feel that this post helps you then do not forget to share and comment below.

Happy Coding 🙂

Sunil Gupta

I am a very enthusiastic Android developer to build solid Android apps. I have a keen interest in developing for Android and have published apps to the Google Play Store. I always open to learning new technologies. For any help drop us a line anytime at

You may also like...

3 Responses

  1. Waheed says:

    Can u please Give Complete Code I m New to Android ….???

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.