java - Check if a key from Hashmap is typed in an AutoCompleteTextView -
i created hashmap<string, string>
populated beforehand.
and want autocompletetextview
tell me, i'm typing if it's in hashmap or not. here's code far :
autocomplete.addtextchangedlistener(new textwatcher() { @override public void ontextchanged(charsequence s, int start, int before, int count) { if(s.length() > 0){ if (map_clients.containskey(s)){ toast.maketext(context, "he's here", toast.length_short).show(); } else { toast.maketext(context, "he's not here", toast.length_short).show(); } } else { } } @override public void beforetextchanged(charsequence s, int start, int count, int after) { } @override public void aftertextchanged(editable s) { } });
it tell me "he's not here" when type text or when select autocompletion.
you need use treemap store data, sorted, , there can best fit code.
your other option use sortedlist or array , use binarysearch implementations speed.
Comments
Post a Comment