Question

Today I been reading the documentation of ArrayAdapter, and found the getFilter() method. In description it says:

Returns a filter that can be used to constrain data with a filtering pattern.

So what is filtering pattern? Is this some thing related to Google only, or it's source coming from computer since?

Was it helpful?

Solution

I believe this is related to AutoCompleteTextViews and so. When you have a TextView which has a list of suggestions and each time the user types in a new character it has to match any suggestion from within the ListView, this is implemented in a Filter inside the ArrayAdapter.

By default, the behavior is compare the entered string with any entry in the ListView that starts with that string. However, you might want to match also those entries that don't just begin with the entered text, but also the ones that in the middle have more words and one of them might start with this text. I guess this is what's meant by filtering pattern.

In this case you would overload the performFiltering() method of the inner Filter class and you would change that pattern.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top