This question already has an answer here:
- Limit text length of EditText in Android 17 answers
I set up a max length of text in an EditText field.
<EditText
android:id="@+id/courseDescriptionField"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:inputType="textMultiLine"
android:lines="5"
android:maxLength="@integer/max_course_description_limit"
android:gravity="left|top" >
</EditText>
The problem for me however is, that, text STOPS appearing after 140 characters, but it still continues to type, except that text just doesn't appear, but however, it does appear in the "buffer" (meaning the suggestion thing) if that's what you would call it.
As a side note, I am using a TextWatcher to keep track of the limit. Is there any way to completely limit the amount of text, so that when there are 140 characters, nothing happens when something other than backspace/delete is pressed?
I had the same problem.
Here is a workaround
Thx to How can I turnoff suggestions in EditText?
I had the same problem. It works perfectly fine when you add this:
to your
EditText
.You may try this
If you want to see a counter label you can use
app:counterEnabled
andandroid:maxLength
, like:DO NOT set
app:counterMaxLength
onTextInputLayout
because it will conflict withandroid:maxLength
resulting into the issue of invisible chars after the text hits the size limit.For me this solution works: