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?

Était-ce utile?

La 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

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top