简体   繁体   English

表单的EditText文本格式

[英]EditText text formatting for forms

I'm looking for a simple way for Android, when a user taps a in a edit text box, it will add a hyphen inbetween the number set. 我正在寻找一种用于Android的简单方法,当用户在编辑文本框中点击时,它将在数字集之间添加一个连字符。 Sort of like a phone number, but will be set in a custom position. 有点像电话号码,但是会设置在自定义位置。

For example Book number 05, CD number 15, track number5 = 0515-5. 例如,书号05,CD号15,曲目号5 = 0515-5。 So when they start typing, the app will automatically enter the hyphen. 因此,当他们开始输入文字时,应用程序会自动输入连字符。

Should I use some type of listener and count how many characters are entered, then when it hits that number of characters, it will add the hyphen? 我应该使用某种类型的侦听器并计算输入了多少个字符,然后当碰到该数目的字符时,会添加连字符吗?

Thanks! 谢谢!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM