Question

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?

Was it helpful?

Solution

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

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