SEARCH FILTER IN ANDROID SQLITE DATABASE AND RECYCLERVIEW

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys welcome to the lower studios will be taking a step backwards look at one of my tutorial which is based on Android SQLite database which recyclerview as occurred trick read update and delete are in this particular tutorial which we had earlier we created and we read some of the data and we had to integrate the update and delete but before we do that I would like to are bring something to our notice web are you be able to create a search our functionality and get such are they cut are details of a recycler view and the about which within the section few and we call the on query text listener actually of the set of a recycler view item so from yeah I'll be going streets under studio we are see of are the soft power of this particular application so be extending more on this will get a search and now we'll be able to search for which item probably you have a long list of cards right in the recyclerview are optically or 20 and you just want to search based on the beneficiary name or your search based on the email address you can easily tap on the search icon at the top and now get your query our turn so our actually be try not to get that in recyclerview layers these on our data from the SQLite database right there are in the rest or by out the menu to send the beneficiary such XML about we have our menu our to actually get such menu implemented and we actually use our the the driver which is our the vector graphics in order to equality peak are the share are the search icon division notice is always black you can easily change the color right there in a few color if you wanted that change to Dec for if you wanted white based on the background and laying this on I think the background is I kind of mind so white will be perfect on that so I made it white and the menu whether we have the beneficiary search I have an ID of search and they call the icon you know from tribal and also set the type to and show us action if there's room and you or you collapse the action view and we call the action view class which is the undress support version seven widget section so I'll show you now I'm going to actually implement all these in the java source we move is just to the beneficiary activities that's where we're going to implement a second topper no after you might have fill in form and you have your recyclerview which card layouts you can tap on the search icon October and sort out our piece on beneficiary deal or these on beneficiary in the largest first consider year I would like to implement so you can easily get the source code this way then in the get up link I sent you in the first tutorial of this club video I will implement search view which is from the widget and we call the on query text listener which is actually from the support which is seven widget as well so we have to make that possibly and we go to add this line of code immediately are after the initialization of objects before you get the data from rescue lines and I'm sure you know we need to actually are creates the options menu with all of the many researchers code so let's write public you call it concrete noxious many hours menu of the Android view as a parameter objects so we're going to get many later and we try to inflate the layout which is the menu layout or the menu and now we call the beneficiary search which is the layout and repass fine now let's call the menu item search our menu objects find item ID search so it's actually finding I'll show you this let's go back to the menu take a look at something but mainly does beneficiary search this idea we have find to the item as such that's what we call him right there in the Java code and we are passing that to the menu items edge now we call the search view which is an object's edge view so cast the class search you just likely where we do when we or text view or image view and find you by ID others know for now we go to call menu item compact which is from the support special for view get the action view which is search now I feel when I use the search view it had set on query text listener this class me too it's on a volume the boolean so we don't you stuff it in that's all so we have the oncreate options menu are right on costs now we still need to override on options item selected if the students or the public also put in options selected as menu item parameter now we need to return super on options item selected our path the item parameter asses it all now we need to provide one other method which is the options no this time it will be on query check submit when you submit the query you made us to fetch no publicity for your name you know so what's going to happen when you submit this how all this method + right ready public also pool in gravy text of this as a string now get off clearly our return false as for the on create sacks of mix now we're going to have one other one which is uncreated tax change when you change the texture elegance and different activities or difference changes on my up on Brady processor clicking the search icon change will be the cycle of your list of public live on query text change a string do that new next time greatest change we're going to call the new text so want you to look at this closely new text about past lowercase so anything you pass in into the search string publish and alpha are using cups is actually going to take that and convert it to the Lockheed special teachers now we call the array list now we want to do some comparison to the list we are at the class sharing new list now we instances with a new ArrayList so we're going to use the for loop so for each beneficiary so the list of beneficiary call the string name equals beneficiary does the beneficiary objects forget and we get the name are we convert to the Rockies we have the beneficiary our model that were created earlier now gets on the name over here this method which returns name and we're now combatant to the Rockies remedy you are much the work is now we submit test for if the name contains the new text ask if it contains what you pass them in as just it the new text which we've actually competent workers are also about the name itself to the Rockies which its most so if it contains district owns the value as just logic now now or the new list add that pattern of energy sure that's nice so without without further done you've been able to compare you know what you're passing inning and what you have in the Lisbon officio with follow and also whether the if statement let's be sure if it contains the new text with other comparison people to Bistro force you need to return the beneficiary with settler data you need to notify the beneficiary circular data which is actually ordinal to the view of the cards I'll call set filter which will be created in their depth our path news so it has to change as SS or that about what students on true perfect now when nature may affect the change by there in the beneficiary supply adapter but if I do that just let me make my are called simple on used pills should be taken off don't keep them look at your fault very well so Twitter right now we're going back to the adapter the beneficiary cycler doctor now we don't need peace with this religionist v our lists at the same time they're going to call the list and officially get the size of all listed official you have in the recyclerview now we're going to implement it measure the air which is public void set user now checks the parameter of the array lists are going to show you also with a new list I will call the list finisher the shades being a realist and the objects mr. Fisher try to add both regards at all from the query which is also the new list all of the new list and we have to notify the recyclerview data set changed pass it on the list in addition we have to defy that I must be a change on the recycle aliens there must be the comparators baton now the at all has actually got the list the values needed and now it must notify the kitchen search engine so I try to show that 250 so that's just outside creates the search if you notice the searches are delegated work and let's go back to the necessary list just a round of our we actually made this work you know we've actually up the array lists or or beneficiaries other we are right there in these SQLite database about we created an object Collins beneficiary alien which is Isis in here as a private I released beneficiary let me show you has been used throughout the sauce what values get in it delete objects pass the values to recyclerview and so on so we get to our operate exchange this actually is the actuality the such you know Baba we have the new list started from there I release and we have a followed to look through the list beneficial with our earlier and now we pass the value of the guest name to lower class of the beneficiary model as in them string now we need to test for what is varied in to what we have ready so does the essence of the if statement is the name contains the new text as this of an official portrait animated show that's very far I will set the new list to the future and this is being posted from the recycle adapter actually make that change the new list and actually adult list and it's not the farm the data set changed to the recycle certainly between source code all these are the application in an emulator and our submission the source code as well stay back the air will go with application will be filling up to for our beneficiaries so so I will be able to test the set our pewter system is solid are the legends ID No em address x2 sternum call our titles id7 key bill after this I do you see one seat here let's search I say let's search for titles you notice that ti3 us attitude don't search more perfectly unless search for our Moses moseys and see that work so that's just it a search for zulia salir considered perfectly our let's search for wealth whether the lists search for let's search for the first person on the list I'm dealing considers it was so this just artistic research pewter into your secular view from the air either from the cloud or from escalating levels thank you very much for you know each other's tutorial please don't forget my channel other one
Info
Channel: Bamidele Oguntuga
Views: 46,747
Rating: undefined out of 5
Keywords: search, filter, recyclerview, linear layout manager, grid, android, sqlite database, cardview, create, read, update, delete, CRUD
Id: PPXiZDWPOcI
Channel Id: undefined
Length: 21min 8sec (1268 seconds)
Published: Mon May 15 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.