Limiting text length of Edittext in Sketchware

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 onTextChanged use the following blocks​:
If length of charSeq > 7 then
Textview edittext1 setText (Textview edittext1 getText substring 0 to 7
else
...
This will limit the input text length to the first 7 characters. With this method, if any extra character is input at the end, it doesn't appear. But if an extra character is input in between the text, the last character disappears to accommodate the input character.

Comments

  1. what about restricting a character text to only 1 from the speech to text function? please help me

    ReplyDelete
  2. How can you make a button that deletes the last character inputted in the edittext view?

    ReplyDelete
    Replies
    1. Block : edittext1 set text ( let it empty )

      Delete

Post a Comment

Popular posts from this blog

A Flash Light App in Sketchware

Create Music Player app in Sketchware

Simple car racing android game in Sketchware

In Sketchware: How to create a calculator for any simple formula?

Firebase auth in Sketchware for Login Activity