Insert hyphen ("dash" -) automatically while user type

Asked

Viewed 422 times

1

Is there any way while the user type in a EditText insert hyphen (-) every 4 characters typed? In the same way some licenses work the dash (-) is already inserted automatically.

  • You can use this https://github.com/toshikurauchi/MaskedEditTextplugin to make it easy.

  • I found it easier @Eduardosilva but gave an error when compiling the app. I don’t remember exactly what it was but it said something that I didn’t have Mask in the plugin indicated.

1 answer

1


Has a cool tutorial and works at runtime here:

Just swap Mask.Insert("###.##.##-##", Cpf) for the mask you want.

  • Could you post an example applying this to Android? Applying to a component swing does not make much sense for the question of the AP.

  • It’s a little complex, but it’s the best I could do

  • 1

    Thanks @Paulocosta solved!!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.