I’m trying to connect actions in Spinner with AutoCompleteTextView. My goal is when user selects some item in spinner, AutoCompleteTextView suggestion list needs to be changed.
Example:
Spinner items: Cats, Dogs, Horses
String1: cat1, cat2, cat3, …
String2: dog1, dog2, dog3, …
String3: horse1, horse2, horse3 …
So when user chooses ‘Dogs’ in spinner and after that clicks on AutoCompleteTextView, he will get following suggestions after he begins to write: dog1, dog2, dog3. Similar for Cats and Horses.
I can’t find a solution for this problem.
I tried to put onClickListener to AutoCompleteTextView but it seems that doesn’t work.
autoCompleteTextView.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
//some actions
});
And there should be some better solution because after the screen opens that AutoCompleteTextView is already selected.
Check out the API for AutoCompleteTextView – http://developer.android.com/reference/android/widget/AutoCompleteTextView.html
The suggestions are populated from a data adapter, so you could modify the data adapter for your autoCOmpleteTextView after the user makes their spinner selection: