The correct input type for credit cards

I am trying to create an input type for a field that will accept credit card numbers.

I used inputType = "number" - but this will not allow people with hardware keyboards to fall into a space .. when they do this, it goes to another field in this operation.

I would like to allow users to use the space in their rooms if they want to, or at least to make users with a hardware keyboard go into space, when I only allow numbers, this will not leave an EditText credit card number.

Ideally, I would be able to implement some kind of interface and have my own inputType type, but I'm not sure if this is possible.

  • Can numbers and spaces be resolved by showing soft keyboard numbers?
+6
source share
3 answers

I do not have a final answer for you, but here are some resources that I took:

I found this hint to β€œcatch” hard keystrokes: β€œ To intercept hard keys, override InputMethodService.onKeyDown () .” Read from the bottom heading "Intercepting Hard Keyboard Events."

If you cannot find a way to intercept and process the β€œspace” key, I would suggest using a regular TextView and manually opening the keyboard with numbers rather than qwerty (go here for more information on general Login Link ). Then you can confirm the keystroke from the hard keyboard.

Sorry, I could not give you a more solid answer!

+1
source
+4
source

What about android:inputType="phone" in your layout xml file?

+2
source

Source: https://habr.com/ru/post/901255/


All Articles