I have a TreeMap and i want to use the string keys as the autoCompleteTextView string array resource. Is it possible? If possible will it be updated every time the i add an entry to the Map?
Asked
Active
Viewed 402 times
1
-
sure: the easiest way is to use SimpleCursorAdapter – pskink Feb 12 '14 at 13:20
-
Can you explain a bit. I am an absolute beginner :-) – GuyZ Feb 12 '14 at 13:34
-
see my answer here http://stackoverflow.com/questions/19858843/how-to-dynamically-add-suggestions-to-autocompletetextview-with-preserving-chara . it uses web response as input data so you need to change it to use your tree – pskink Feb 12 '14 at 14:36
1 Answers
0
I think he meant how to convert the key set of the map into a string array, so he'll be able to display it in a simple ArrayAdapter and use it in an AutoCompleteTextView
TreeMap<String, Object> map = new TreeMap<String, Object>();
AutoCompleteTextView tv = new AutoCompleteTextView(getActivity());
String[] yourArray = map.keySet().toArray(new String[map.size()]);
ArrayAdapter<String> adapter = new ArrayAdapter<String>(getActivity(), android.R.layout.simple_list_item_1, yourArray);
Hope this helps

orelzion
- 2,452
- 4
- 30
- 46
-
if he accepted it, he is ok with the fact he lost any benefits of fast data structure that TreeMap is – pskink Feb 13 '14 at 10:18
-
@pskink Perhaps you would expand a bit more, on how this is going to help him if he only wants to display a simple string list? – orelzion Feb 13 '14 at 11:50