EditText : set number of characters programmatically

后端 未结 4 1105
伪装坚强ぢ
伪装坚强ぢ 2020-12-29 06:26

I have a EditText , and I would like to restrict the number of characters which could be inputted in this EditText, and make this

4条回答
  •  温柔的废话
    2020-12-29 06:50

    public void setEditTextMaxLength(int length) {
        InputFilter[] FilterArray = new InputFilter[1];
        FilterArray[0] = new InputFilter.LengthFilter(length);
        edt_text.setFilters(FilterArray);
    }
    

提交回复
热议问题