This is my xml
<EditText
android:id="@+id/et_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textNoSuggestions|textVisiblePassword"
android:hint="Provide comments here..."
android:gravity="top"
android:maxLength="5"
android:textSize="12sp"
android:visibility="visible"
/>
Neither is it working using this code
TextView editEntryView = new TextView(...);
InputFilter[] filterArray = new InputFilter[1];
filterArray[0] = new InputFilter.LengthFilter(5);
editEntryView.setFilters(filterArray);
maxLenth is not working, I dont know why, but it isnt.
I have checked other answers on the stack but they are also not working.
Please check if any of EditText attributes are conflicting or what is the problem?
EDIT: Same problem is being faced by other developers
See comments here same problem is being faced by Mansi and aat
And here in comments same problem is being faced by Vincy and Riser
EDIT: Problem solved
I was using input filter which overrides the max length in xml making it not able to work.
The reason input filter didn't worked for me was that I was using another input filter which overwrites the previous maxLength input filter.
Making it into a single input filter fixed that issue for me.
If you are using InputFilter for the edittext, then maxLength will not work.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With