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?
Solution 1:
Making Items in an
ArrayAdapter
filterable:ArrayAdapter
has a built inArrayFilter
, It compares the Objects in adapter list by using a string fromtoString().toLowerCase()
for each object. If you overridetoString()
inCityData
class and return city name, thenArrayAdapter
should be able to filter items effectively.Enabling Automatic text filter on a
ListView
: InListView
either useandroid:textFilterEnabled="true"
in layout or set it from code usingsetTextFilterEnabled(true)
. Now wheneverlistView
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
: UsesetFilterText()
method ofListView
. 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?"