安卓格式的EditText每4个字符后的展示空间 [英] android format edittext to display spaces after every 4 characters
问题描述
Android的 - 我想从用户到一个EditText多个输入 - 它需要用空格隔开 - 每4个字符。 示例:123456781234 - > 1234 5678 1234
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?
推荐答案
您需要使用的 TextWatcher 以达到视觉目的的空间。
You need to use TextWatcher to achieve visual purpose spaces.
和使用任何简单的分割字符串空间的逻辑来加入吧背部或遍历每个字符的整个字符串智慧和消除(字符)32
从字符串
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
这篇关于安卓格式的EditText每4个字符后的展示空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!