質問

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?

役に立ちましたか?

解決

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

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top