0

I am developing an android application with some forms. Here in my input fields description section should not allow the user to enter more than 5 lines.I am not getting how to prevent the user to enter more than 5 lines in edit text field. I already tried android:maxLines=5 and android:lines=5. But those are not giving my functionality. could any one please suggest a way to stop entering more than 5 lines in edit text.

Thanks in advance

Raghu Mudem
  • 6,793
  • 13
  • 48
  • 69
  • Check this question here: [EditText maxLines not working - user can still input more lines than set](http://stackoverflow.com/questions/7092961/edittext-maxlines-not-working-user-can-still-input-more-lines-than-set). See the answer by _Indrek Kõue_. – Siddharth Lele Feb 11 '13 at 07:21

3 Answers3

0

Validate the field when the user tries to submit it. Use a prompt to notify the user of the required length.

Montycarlo
  • 735
  • 3
  • 16
0

android:maxLines and android:lines limits the number of visible lines, android:maxLines=5 expands the edittext up to 5 lines, and android:lines=5 creates a span of 5 lines.

if you want to limit the length of the input you need to use the android:maxLength=5 as shown in this answer: https://stackoverflow.com/a/3285421/1056359

Community
  • 1
  • 1
thepoosh
  • 12,497
  • 15
  • 73
  • 132
0

mmm, i think this need more calculations depending on font size and the line width, so in this case i prefer just to set the maxLength attribute to like 100 character, otherwise you need to calculate the current text size while user typing into it.

Mohammad Ersan
  • 12,304
  • 8
  • 54
  • 77