带有自定义标记器的Android MultiAutoCompleteTextView,如whatsapp GroupChat [英] Android MultiAutoCompleteTextView with custom tokenizer like as whatsapp GroupChat
问题描述
我想为@h创建自定义标记器,如同whatspp功能一样(当打开组并写入@然后打开弹出窗口列表,用户可以选择任何用户。也可以删除该字符串@。
我搜索了很多东西。但我发现了像搜索功能一样的推特
我的问题得到了解决方案。
我创建了n multiautocompletetextview的自定义视图,并在@sign之后为打开的弹出窗口添加performFiltering方法。
公共类KcsMultiAutoCompleteTextView扩展MultiAutoCompleteTextView {
public KcsMultiAutoCompleteTextView(Context context){
super(context);
}
public KcsMultiAutoCompleteTextView(Context context,AttributeSet attrs){
super(context,attrs);
}
public KcsMultiAutoCompleteTextView(Context context,AttributeSet attrs,int defStyleAttr){
super(context,attrs,defStyleAttr);
}
@Override
protected void performFiltering(CharSequence text,int start,int end,int keyCode){
if(text.charAt(start)== '@'){
start = start + 1;
} else {
text = text.subSequence(0,start);
for(int i = start; i< end; i ++){
text = text +*;
}
}
super.performFiltering(text,start,end,keyCode);
}
}
I want to create custom tokenizer for @ like as whatspp feature(when open group and write @ then open popup for list and user can select any.also user can remove that string of @ .
I have search lots of things.but i have found twitter like search feature Example like twitter,
but in this,when user can write @ then do not show popup window of list. user can write soemthing after @ then based on typing ,popup window will show search result.
I want to show something like this:
Thanks in advanced.
I got solution for my question.
i have create own custom view for multiautocompletetextview and add performFiltering method for open popup after @sign.
public class KcsMultiAutoCompleteTextView extends MultiAutoCompleteTextView {
public KcsMultiAutoCompleteTextView(Context context) {
super(context);
}
public KcsMultiAutoCompleteTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public KcsMultiAutoCompleteTextView(Context context, AttributeSet attrs, int defStyleAttr) {
super(context, attrs, defStyleAttr);
}
@Override
protected void performFiltering(CharSequence text, int start, int end, int keyCode) {
if (text.charAt(start) == '@') {
start = start + 1;
} else {
text = text.subSequence(0, start);
for (int i = start; i < end; i++) {
text = text + "*";
}
}
super.performFiltering(text, start, end, keyCode);
}
}
这篇关于带有自定义标记器的Android MultiAutoCompleteTextView,如whatsapp GroupChat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!