問題描述
Android - 我想將用戶輸入的數字輸入 EditText - 它需要用空格分隔 - 每 4 個字符.示例:123456781234 -> 1234 5678 1234
這僅用于視覺目的.但是我需要不帶空格的字符串以供進一步使用.
我能做到這一點的最簡單方法是什么?
需要使用TextWatcher 實現視覺目的空間.
并使用任何簡單的 按空格分割字符串 邏輯將其加入或循環遍歷每個字符的整個字符串,并從字符串中消除 (char) 32
p>
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
這篇關于android格式edittext每4個字符后顯示空格的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!