2

This is the code I'm using:

MultiAutoCompleteTextView selectedCities = (MultiAutoCompleteTextView)findViewById(R.id.citiesSelected);

String[] cities = getResources().getStringArray(R.array.cities);

ArrayAdapter<String> adapter = new ArrayAdapter<String> (this,android.R.layout.simple_list_item_1,cities);
        selectedCities.setAdapter(adapter);
        selectedCities.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());

but when i want to add items it is possible to add any string not from my list...

I dont want to use Alert Dialog with MultiChoiceItems since I have more than 200 items on my list.

Thanks!!

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
user3698465
  • 185
  • 1
  • 10

1 Answers1

1

I know this is an old question but if you still have this problem, you can do this in at least two ways:

  1. You can add an onFocusChangeListener and then perform your validation inside of that.
  2. You can have your activity implement TextWatcher and then override:
@Override
public void afterTextChanged(Editable s) {
        // validation code goes here
}

About the last one, take a look at this question: Android: How can I validate EditText input?.

Community
  • 1
  • 1
Aurasphere
  • 3,841
  • 12
  • 44
  • 71