[Android] EditText의 최대 입력 가능 길이 제한에 관한 코드

EditText를 이용하여 텍스트를 입력 받을 때 특정한 길이만큼 제한을 줄 필요가 있다.

상위클래스인 TextView의 android:maxLength라는 xml attribute를 이용해도 되겠지만,
xml의 layout을 사용하지 않고 code상에서 구현을 할 수도 있다. 당연히.......ㅎㅎ
editor = new EditText(this);
editor.setSingleLine();
int maxLength = 32;
InputFilter[] filterArray = new InputFilter[1];
filterArray[0] = new InputFilter.LengthFilter(maxLength);
editor.setFilters(filterArray);
요렇게 하면 한줄로 된, 32글자까지 입력을 받을 수 있는 EditText를 만들 수 있다. ^^

출처 : http://chaotic21c.egloos.com/10537099