I am developing an application which has about 8000 names of the cities of India. And when the user types in i use auto complete to help the user to do the job. But some city names have spelling which is hard to guess for people from other states. So we need a approximate string matching for auto complete rather than exact matching which comes by default.
For example there are names like
And also
If a user search for the city 'Tirunelveli' But types in text box as 'Thirunel' the autocompletetextview doens't show the name and it does a exact string match.
What should i do to get approximate matching strings in the auto complete drop down list..
After alot of search and experiments i found the solution myself..
To do custom string matching we need a custom array adapter which we need to extend ArrayAdapter class and write our own string matching algorithm.
We need to overide getFilter
method of ArrayAdapter class for this functionality and add getItem
and getCount
methods to our custom adapter class.