Limiting text length of Edittext in Sketchware
1 minute read
If you want the user to provide only a certain type of text input in the Edittext field, it can easily be done by selecting appropriate option for input_type from text properties.
The image below shows the input_type options:
However, maxLength or any other option to limit length of input text, is not available in Sketchware. Which means you have to use code blocks in Logic area.
To limit the input text length (suppose to 7 characters), in Edittext: edittext1
The image below shows the input_type options:
However, maxLength or any other option to limit length of input text, is not available in Sketchware. Which means you have to use code blocks in Logic area.
To limit the input text length (suppose to 7 characters), in Edittext: edittext1
apply InputFilter to the EditText field. In onCreate event, use an add source directly block and put following codes:
InputFilter[] filterArray = new InputFilter[1];
filterArray[0] = new InputFilter.LengthFilter(7);
edittext1.setFilters(filterArray);