In this tutorial we will cover how to search a listmap.
Build your layout
Add an edittext and in the properties change the background color to transparent or white (depending on your layout). Change the hint to the word 'Search...' This is where the user will write their query.
Optional:
You can set up your logic to hide or show the search field. You can do this by adding a linear H on top of your listview.
Inside your linear place an imageview. Change the image to an image of your choice. This will be our search button. Set this to set the edittext and the cancel button visible.
Add another imageview. Set the image to anything that you feel your user will understand to mean 'cancel'. Set this to clear and hide the edittext, as well as the cancel button.
In your onCreate event, set the edittext and the cancel button to 'gone'.
Position your linear inbetween the imageviews. as shown in the image above
Once that has been done, navigate to the onStart event of your list.
YOU MIGHT ALSO LIKE: How to search a firebase list using Sketchware
Create a string variable
Create a string with the name 'saved' or any name of your choice. Add a Json to string block and set up the block as follows.
Modify list 'onStart' logic
Add the above block to your listmap onStart logic. Your logic should look as shown below.
Set up 'edittext changed' logic
Once your logic onStart has been set, navigate to the on edittext changed event.
In your edittext place create two number variables. Name these variables length and r. If you already have variables with those names you can give them your own custom name. Just make sure they correspond.
That's all we need. We can now run the app and if we type anything in the edittext, it will only show items which contain the specific character sequence.
Comments