I want to limit the text length of edit text ui element via code:
EditText et = (EditText) parent.findViewById(R.id.smsBody);;
int maxLength = 300;
InputFilter[] FilterArray = new InputFilter[1];
FilterArray[0] = new InputFilter.LengthFilter(maxLength);
et.setFilters(FilterArray);
But this gives me a null pointer exception in the last line. Any ideas whats wrong? This codes is in the onPostExecute
method of my async task class. Parent
is the main activity.