我使用MultiAutoCompleteTextView在消息传递应用中选择多个收件人,但我只想将其限制为两个收件人或3.一旦达到限制,用户就不能再添加更多收件人。任何提示如何做到这一点?
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);