How to stop taking input after EditText length crosses a limit

元气小坏坏 提交于 2019-12-04 03:21:51

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

As @Madhur sugested, in your EditText xml add next line:

Documentation

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