Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android EditText Max Length [duplicate]

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?

like image 318
Jon Wei Avatar asked Aug 23 '12 00:08

Jon Wei


People also ask

How to set max length to editText in Android?

This example demonstrate about How to limit text length of EditText in Android. Step 1 − Create a new project in Android Studio, go to File ⇒ New Project and fill all required details to create a new project. Step 2 − Add the following code to res/layout/activity_main.

What is text view in Android?

TextView is the user interface which displays the text message on the screen to the user. It is based on the layout size, style, and color, etc. TextView is used to set and display the text according to our specifications.


Video Answer


1 Answers

Possible duplicate of Limit text length of EditText in Android

Use android:maxLength="140"

That should work. :)

Hope that helps

like image 166
Ushal Naidoo Avatar answered Oct 21 '22 18:10

Ushal Naidoo