Search code examples
androidlistviewfilteradapterradix

Android: ListView making a search Filter


Is there a way to create a search filter over my custom list view which created using BaseAdapter rather than ArrayAdapter, because I have only come across methods that are using ArrayAdapters in there Custom List Views. Follwing is what I have come acrossMaking a filter using Array Adapter


Solution

  • If you're using List collection then extend ArrayAdapter - it's subclass of BaseAdapter.

    Override getView method (In your case just copy your old getView code with little modifications).

    Override toString of object that is in your collection and set:

    listView.setTextFilterEnabled(true);