Filter View - For ListView

Hello Everyone,

Today I am going to share a most useful feature for list view that is Filter View with Spinner and with Check Box.

Filter view can filter the list items according to their categories. This is the most useful feature in E-commerce apps to filter the products with their categories.

Please note that, this Filter View is exclusively for filtering list according to the category of each list item.

This is main Title List and another is Category List.

On Screen Initialize, Set List view elements to Title list.

Spinner is used to choose or select Category.

Spinner elements set to Categories by removing duplicate categories.

  1. Global variable TempList is created to store temporary list items which will be filtered.

  2. Global variable Index is used to store index of selected category from category list.

  3. Global variable NewList is used to store new list that will be created after filtering TempList.

7

After selecting spinner item:

  1. First, I am creating Temperory list of categories and stored in TempList Variable.

  2. Now for each item in TempList, I am getting the index of selected spinner item and storing it in Index variable.

To avoid repeated same index number, I am replacing previous list item.

  1. Now by using the Indexes of selected category, I am getting Titles from Title list and storing it in NewList

This NewList can be used as Filtered List

Same logic is applied with Check boxes, in place of spinner selection here used Check box text.

Downloads

Filter.aia (15.6 KB)

Filter.apk (5.4 MB)

You can apply this logic for any type of list view, here I have applied for simple ListView.

Please give feedback, if this is really helpful to you.

Donate something to support

23 Likes

Very god work! I think you can try reducing the use of loops, because it takes up lots of memories.

For example, in the first step, you can just set the list to the removed duplicates list and insert “Selected” in the list of index 1.

And I think using data type like dictionary, list of pairs might be more useful :wink:

2 Likes

Loop is necessary in 1st step because when you try to get index of a list item which has duplicates it will return index of only first duplicate and same index will be shown for all duplicates.

Here, I need index of all duplicates.

That’s why, I am first getting index of first duplicate and then changing it to as “Selected” so, that in next loop this duplicate will be ignored and index of next duplicate will get.

First, I tried with dictionary but not got succeed. I think you can do it better. :grinning_face_with_smiling_eyes:

1 Like

Hello friend, excellent tutorial, could you help me with something?
In my application I have a dynamic cardview list of registered users who publish their work (they each have their photo and rating bar with the user’s qualifications) I need people to be able to filter the professionals by place of residence. I need to create a filter for it and I have no idea how I can do it. Will you know how to do it? Thank you very much

i am using firebase to store the data users.

1 Like

Yes, I will try.

Please create a new topic and post your blocks.

Very Helpful Guide

1 Like

For which thing u want filter
like :- rating or anything?

Rating, city of the user, more reviews. etc

For rating u can use this :grin: