FORUMS
Remove All Ads from XDA

sort the AutoCompleteTextView list

2 posts
Thanks Meter: 0
 
By alessandro_, Junior Member on 4th February 2010, 11:39 AM
Post Reply Email Thread
Hi!

I have an alphabetically sorted list of strings for the AutoCompleteTextView,
some strings have 2 words,
when I type a letter, I would that the autocomplete list that appear shows the strings sorted by the letter typed

for example:
I have this list alphabetically sorted: New Orleans, Omaha, Portland, Rome

now, if I type 'O', the first string in the autocomplete list, is New Orleans, the second Omaha,
but I would that Omaha is the first string because it start with 'O' and after New Orleans that doesn't
7th February 2010, 04:01 PM |#2  
Senior Member
Thanks Meter: 13
 
More
You should probably use a custom adapter and filter which sorts the results before returning them. Implement Filterable in your custom adapter, subclass http://developer.android.com/referen...et/Filter.html, which does the filtering and calls Comparator.sort before returning any results. When getFilter() is called on your adapter, return an instance of your Filter subclass.
11th February 2010, 12:55 PM |#3  
OP Junior Member
Thanks Meter: 0
 
More
thank you for the answer,

I have solved the problem modifying the code of ArrayAdapter
20th November 2010, 04:33 PM |#4  
elkriefy's Avatar
Junior Member
Thanks Meter: 0
 
More
can you please post a sample source for the filter part?
i have a custom adapter in the list and i need to implement filter on it.
24th October 2019, 11:07 AM |#5  
Junior Member
Thanks Meter: 0
 
More
Can you please let me know how this is achieved? I am having the same issue and could not be able to find the solution
Post Reply Subscribe to Thread

Guest Quick Reply (no urls or BBcode)
Message:
Previous Thread Next Thread
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes