Skip to content Skip to sidebar Skip to footer

I Have A Listview Which Contains More That 1 Value In A Row, How Can I Filter The List With A Name Value When I Type In Edittext?

If there was just one value in a row. I got the answer but i have more than one. This my main class which i couldnt decide how to fill Textwatcher stuff. 'CityArray' is the class w

Solution 1:

  • Making Items in an ArrayAdapter filterable: ArrayAdapter has a built in ArrayFilter , It compares the Objects in adapter list by using a string from toString().toLowerCase() for each object. If you override toString() in CityData class and return city name, then ArrayAdapter should be able to filter items effectively.

  • Enabling Automatic text filter on a ListView: In ListView either use android:textFilterEnabled="true" in layout or set it from code using setTextFilterEnabled(true). Now whenever listView is in focus, user can simply bring up the keyboard, and start typing, list items will be automatically filtered.

  • Explicitly setting text filter on a ListView: Use setFilterText() method of ListView. Do not forget to clear this afterward.

You can reveal more details by examining the relevant Android Sources.


Post a Comment for "I Have A Listview Which Contains More That 1 Value In A Row, How Can I Filter The List With A Name Value When I Type In Edittext?"