Reputation: 23
I have the following EditText
where I have set maximum character limit to 10, but somehow it is not working. It accepts more than 10 characters.
<EditText
android:id="@+id/txtName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:gravity="left|center"
android:hint="Enter Full Name *"
android:maxLength="10"
android:padding="5dip" />
Please helps, thanks in advance.
Upvotes: 2
Views: 1223
Reputation: 2314
Make sure that you don't have any InputFilter
set to the EditText
by code.
You should comment this line of code.
editText.setFilters(new InputFilter[] { filter });
Upvotes: 1
Reputation: 991
You can try with this. This is the simple hack around this problem if you are setting it from xml.
Internally if your suggestion is switched on then as per dictionary its not able to judge the word character length. So If it has been switched off then maxlength will work and Android will understand it as own written word,where no dictionary should be applicable.
android:inputType="textNoSuggestions|textVisiblePassword"
android:maxLength="10"
Upvotes: 0