0

I have disabled the suggestions on my EditText when a certain character limit is reached using

mEditQuestionBox.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

I, however, need the suggestions capability back if the user were to press backspace and type again. Help?

Essentially It boils down to this. Is there an InputType available to enable the suggestions again? If not, can anyone think of a workaround?

Nairiya
  • 33
  • 1
  • 5

1 Answers1

1

implement onTextChanged() according to your need in addTextChangeListener on EditText.

mEditQuestionBox.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) {
            if(s.length()< threshold){
                mEditQuestionBox.setInputType(InputType. TYPE_CLASS_TEXT);
            }
            if(s.length()>= threshold){
                mEditQuestionBox.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);
            }
        }

        @Override
        public void afterTextChanged(Editable s) {

        }
    });
harshitpthk
  • 4,058
  • 2
  • 24
  • 32