How to stop taking input after EditText length crosses a limit

Just add this to your EditText. It will definitely work.

 android:inputType="textFilter"

I tried the same and it worked for me.


try this,

android:inputType="textNoSuggestions|textVisiblePassword"
android:maxLength="7"

OR

edittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS);

OR

android:inputType="textFilter"

This finally works for me:

edittext.setInputType(InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD);