java - how to set multiple token in MultiAutoCompleteTextview Android -
i need set different adapters different token (i.e when type '@' should call atmentionedadapter , when type '#' should call hashadapter , both has in same multiautocompletetextview
please find sample code have used working @ not hash
multitextview.settokenizer(new multiautocompletetextview.tokenizer() { @override public charsequence terminatetoken(charsequence text) { int = 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 + " "; } } } @override public int findtokenstart(charsequence text, int cursor) { int = cursor; while ((i > 0 && text.charat(i - 1) != '@') || (i > 0 && text.charat(i - 1) != '#')) { i--; } //check if token started @, else don't have valid token if (i < 1 || text.charat(i - 1) != '@') { return cursor; } if (i < 1 || text.charat(i - 1) != '#') { return cursor; } return i; } @override public int findtokenend(charsequence text, int cursor) { int = cursor; int len = text.length(); while (i < len) { if (text.charat(i) == ' ') { return i; } else { i++; } } return len; } });
can me in please got stuck on
Comments
Post a Comment