i’m new to android. I’m just trying to make one simple search functionality for my app. My app consists one ListView one EditText and one Button for search. My ListView contents are listed from database using custom adapter which is extends BaseAdapter
Now, what i’m trying to do is, i want to search any records from ListView For example, if i’ve some records like
Optimization, Operations, Data Mining, Computer Ethics, Computer Architecture and etc…
So, when i type some record name like op
The listview should listed the records which is started from op... I’ve referred something for this, from i got addTextChangedListener But, i don’t know how to do this?
And, Can we do this same functionality with click of button
Has anyone having any idea on this? Thanks in advance.
I had asked a similar kinda question a while back. Here: Filtering a ListView with Baseadapter filters text not images. Although, my specific question concerned a GridView, the concept (and the code) can be substituted for a ListView.
NOTE: This will be a lengthy post but I think necessary for the sake of completeness (I am leaving out the
importsthough)The main activity (Friends.java)
The getFriends.java class for the
ArrayList:And finally, the adapter class (FriendsAdapter.java)
You can use the concept here and substitute for your ListView. I have used this elsewhere for a ListView and works as it should. Unfortunately, I cannot give that code away on a public fora. Hope this helps you though. Again, a very lengthy post no doubt, but necessary I believe.