Show only numeric keyboard for EditField
-
27-06-2021 - |
Pergunta
I have EditField. I want to show virtual keyboard only with number, without letters. Is it possible?
Solução
editText.setInputType(InputType.TYPE_CLASS_NUMBER);
Outras dicas
You can also use
object.setFilter(TextFilter.get(TextFilter.NUMERIC));
amount->setInputMode(bb::cascades::TextFieldInputMode::NumbersAndPunctuation);
You can find all the types here: https://developer.blackberry.com/cascades/reference/bb__cascades__textfieldinputmode.html
You can either construct the EditField and pass EditField.FILTER_NUMERIC
as the style: http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/ui/component/BasicEditField.html#FILTER_NUMERIC
OR
You can call EditField.setFilter()
http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/ui/component/BasicEditField.html#setFilter(net.rim.device.api.ui.text.TextFilter) and pass in aTextFilter
. Use the static TextFilter.get()
function and pass in one of the filter constants from the TextFilter
class, eg http://www.blackberry.com/developers/docs/7.0.0api/net/rim/device/api/ui/text/TextFilter.html#NUMERIC
Numeric filters accept non-negative integers only (0 - 999999999 and beyond), Integer filter accepts all integers negative, zero and positive, and REAL_NUMERIC accepts any decimal number (negative, zero, positive, with an optional decimal point).