3

我有 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);
4

0 回答 0