Skip to content Skip to sidebar Skip to footer

Searchview On Actionbar: How To Perform Sqlite Search On A Custom Listview With Custom Adapter?

I have a custom ListView with multiple EditTexts and I would like to make the searching function work with only one of the EditTexts. I was able to implement the SearchView on the

Solution 1:

If you use ArrayAdapter, it provides easy method getFilter() which will filter data out in the list according to search text. But to use same functionality with database you need to use CursorAdapter : Documentation

Which provides method setFilterQueryProvider(filterQueryProvider) Where you need to pass the text and according query in database class. See below tutorial which provides exact implementation of this:

http://www.mysamplecode.com/2012/07/android-listview-cursoradapter-sqlite.html

Hope this helped!

Solution 2:

I can't tell from your question if you are trying to provide the list of suggestions that drop down when user is typing, or if you want to just handle the search by running your query and displaying results in your UI.

In either case you need to write a content provider. You should already be familiar with content providers if you are using SQLite, but if not, you should probably Start Here

If you are trying to populate the list of suggestions, it's fairly easy task to define your content provider by just extending the SearchRecentSuggestionsProvider. There is alot of information on this here

Post a Comment for "Searchview On Actionbar: How To Perform Sqlite Search On A Custom Listview With Custom Adapter?"