Android MultiAutoCompleteTextView with custom tokenizer like as whatsapp GroupChat

回眸只為那壹抹淺笑 提交于 2020-01-14 05:08:48

问题


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.


回答1:


Please see TokenAutoComplete, I hope it help




回答2:


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);
    }

}


来源:https://stackoverflow.com/questions/40460997/android-multiautocompletetextview-with-custom-tokenizer-like-as-whatsapp-groupch

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!