0

I am working on a MultiAutoCompleteTextView mactv. My purpose is to read every word added in the mactv during typing and do somethings with that word. For this, I am using TextWatcher to read the last word whenever space is typed in the mactv. The logic for this is implemented in afterTextChanged() method. But its not working correctly. So, I want to debug the app while inputting text in mactv, but the app is crashing after the first call of afterTextChanged() method. I have already set breakpoints before setContentView() methods of mainActivity and present Activity.

So, is there a way to debug this TextWatcher or to achieve this purpose by some other way?

Note: I have created a custom tokenizer which puts only space when items are clicked in auto complete list. And app is not crashing during normal run.

mactv.addTextChangedListener(new TextWatcher() {
        @Override
        public void beforeTextChanged(CharSequence s, int start, int count, int after) {

        }

        @Override
        public void onTextChanged(CharSequence s, int start, int before, int count) {

        }

        @Override
        public void afterTextChanged(Editable s) {

            String text = mactv.getText().toString();
            int lastIndex = text.length()-1;
            int i;
            if(text.length()>0 && text.charAt(lastIndex) == ' '){
                i = lastIndex;
                while(i>0 && text.charAt(i)!=' ')
                    i--;
                String word = text.subSequence(i, text.length()).toString();
                addTagInContainer(word);
            }

        }

    });
4

0 回答 0