简体   繁体   中英

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. 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. 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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