Android中设定EditText的输入长度

方法一:可以在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)});
posted @ 2016-09-20 16:26  仲长可倾  阅读(2203)  评论(0编辑  收藏  举报