Home > Net >  How do you limit the number of characters used for that username for java android?
How do you limit the number of characters used for that username for java android?

Time:02-10

When adding value to a username in an Android app, how do you limit the number of characters used for that username?

CodePudding user response:

private static final int MAX_NUM = 12;

et_name.setFilters(new InputFilter[] { new InputFilter.LengthFilter(MAX_NUM) });

correct the answers.Please help me...

CodePudding user response:

Add android:maxLength in xml

Example Code:

<EditText
     android:layout_width="wrap_content"
     android:layout_height="wrap_content"
     android:maxLength="20"/>
  •  Tags:  
  • Related