user510164 user510164 - 4 months ago 61
Android Question

android format edittext to display spaces after every 4 characters

Android - I want to get a number input from the user into an EditText - it needs to be separated by spaces - every 4 characters.
Example: 123456781234 -> 1234 5678 1234

This is only for visual purpose. However i need the string without spaces for further usage.

What is the easiest way I can do this?


You need to use TextWatcher to achieve visual purpose spaces.

And use any simply split string by space logic to join it back or loop through the entire string per character wise and eliminate (char) 32 from the string