简体   繁体   中英

Number Keyboard and input type=“text”

Does anyone knows how to show automatically the number keyboard on input type="text" on touch devices?

I can't use input type="number" because of german number format with dots and commas like 1.000.000,00

It's for the javascript tool heizkostenrechner.eu and there are so many input fields and a solution would improve the usability very much.

to set the EditText characters

yourEditText.setInputType(InputType.TYPE_CLASS_NUMBER);

you can use class with a flag to create decimal like:

yourEditText.setInputType(InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL);

but it wont add ',' to it

check Input Types for more information about types of flags and classes

however if you want to add numbers and ',' and '.' you can use this code

yourEditText.setKeyListener(DigitsKeyListener.getInstance("0123456789.,"));

this will allow 0123456789 and '.' and ',' and you can add more characters if you want.

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