Android中设定EditText的输入长度

如何限定Android的Text中的输入长度呢?
方法一:可以在layout xml中加上属性android:maxLength
比如:
<EditText
        android:id="@+id/editTextShow"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/hint"
        android:cursorVisible="false"
        android:lines="1"
        android:maxLength="16"
        />
 
方法二:在代码中控制
editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(20)});
原文地址:https://www.cnblogs.com/kakafra/p/2698423.html