How to limit items / inputs of a MultiAutoCompleteTextView

I have a MultiAutoCompleteTextView to select multiple recipients in a messaging app, but I just want to limit it to only two recipients or 3. The user should not be able to add more recipients after the limit is reached. Any hints how to do this?

final MultiAutoCompleteTextView mtv = (MultiAutoCompleteTextView) this
                    .findViewById(R.id.to);
            final MobilePhoneAdapter mpa = new MobilePhoneAdapter(this);
            final SharedPreferences p = PreferenceManager
                    .getDefaultSharedPreferences(this);
            MobilePhoneAdapter.setMobileNumbersOnly(p.getBoolean(
                    PreferencesActivity.PREFS_MOBILE_ONLY, false));
            mtv.setThreshold(2);
            mtv.setAdapter(mpa);
            ((MultiAutoCompleteTextView) mtv).setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
            mtv.setText(to);

      

+3


source to share





All Articles