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.
Global variable TempList is created to store temporary list items which will be filtered.
Global variable Index is used to store index of selected category from category list.
Global variable NewList is used to store new list that will be created after filtering TempList.
After selecting spinner item:
First, I am creating Temperory list of categories and stored in TempList Variable.
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.
- 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.
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