Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- String asd[]={"A","B","C","AAA","BBB","CCC"};
- private static final String[] COUNTRIES = new String[] {"Belgium", "France", "Italy", "Germany", "Spain"};
- ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_dropdown_item_1line, COUNTRIES);
- MultiAutoCompleteTextView textView = (MultiAutoCompleteTextView) findViewById(R.id.edit);
- textView.setAdapter(adapter);
- textView.setTokenizer(new MultiAutoCompleteTextView.CommaTokenizer());
- public static class SemicolonTokenizer implements Tokenizer {
- public int findTokenStart(CharSequence text, int cursor) {
- int i = cursor;
- while (i > 0 && text.charAt(i - 1) != ';') {
- i--;
- }
- while (i < cursor && text.charAt(i) == ' ') {
- i++;
- }
- return i;
- }
- public int findTokenEnd(CharSequence text, int cursor) {
- int i = cursor;
- int len = text.length();
- while (i < len) {
- if (text.charAt(i) == ';') {
- return i;
- } else {
- i++;
- }
- }
- return len;
- }
- public CharSequence terminateToken(CharSequence text) {
- int i = text.length();
- while (i > 0 && text.charAt(i - 1) == ' ') {
- i--;
- }
- if (i > 0 && text.charAt(i - 1) == ';') {
- return text;
- } else {
- if (text instanceof Spanned) {
- SpannableString sp = new SpannableString(text + "; ");
- TextUtils.copySpansFrom((Spanned) text, 0, text.length(),
- Object.class, sp, 0);
- return sp;
- } else {
- return text + "; ";
- }
- }
- textView.setTokenizer(new SemicolonTokenizer());
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement