I want to limit the text length of the text of the text of the ui element through 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 on the last line. Any ideas on something wrong? These codes are in the onPostExecute method of my async task class. Parent is the main activity.
source share