I am asking myself if it is possible, to combine a Spinner
and a AutoCompleteTextView
. Basically I want an AutoCompleteTextView
, that shows all entries from Array
when I click it.
Does anybody know how to do that?
I am asking myself if it is possible, to combine a Spinner
and a AutoCompleteTextView
. Basically I want an AutoCompleteTextView
, that shows all entries from Array
when I click it.
Does anybody know how to do that?
Try this code:
ArrayAdapter myAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, YOUR_ARRAY); myAutoCompleteTextView.setAdapter(myAdapter );
Just found out that this does exactly what I was asking for:
final AutoCompleteTextView textView; final ArrayAdapter<String> arrayAdapter = new ArrayAdapter<String>( getActivity(), android.R.layout.simple_dropdown_item_1line, getResources().getStringArray(R.array.names)); textView = (AutoCompleteTextView) v.findViewById(R.id.txtViewNames); textView.setAdapter(arrayAdapter); textView.setOnClickListener(new View.OnClickListener() { @Override public void onClick(final View arg0) { textView.showDropDown(); } });