开发者

Why numeric constraint didn't work on Virtual keyboard in LWUIT?

开发者 https://www.devze.com 2023-04-09 03:13 出处:网络
I have tested many ways to give the numeric and password constraint in the TextField. But its not working, See the below code.

I have tested many ways to give the numeric and password constraint in the TextField. But its not working, See the below code.

textField.setConstraint(TextField.NUMERIC | TextField.PASSWORD);
textField.setInputModeOrder(new String[]{"123"});

Above code should work on the non touch mobiles. But its not working on the touch mobiles. So i have set the input mode value for VKB and bind that TextF开发者_运维知识库ield with VKB, see this code.

TextField txt = new TextField(); 
txt.setConstraint(TextField.NUMERIC |TextField.PASSWORD); 
txt.setInputModeOrder(new String[]{"123"});
VirtualKeyboard vkb = new VirtualKeyboard(); 
vkb.setInputModeOrder(new String[]{VirtualKeyboard.NUMBERS_MODE});  
VirtualKeyboard.bindVirtualKeyboard(txt, vkb);

VirtualKeyboard.NUMBERS_MODE not working when I use above code. VKB showing as usual format. That means AlphaNumeric format. Why its showing like this?


This is a bug in LWUIT, thanks for bringing it to our attention I'll try to commit a fix for it in the next couple of weeks. It would be sooner but we need to fly to JavaOne soon.

If you want to try the fix locally just update this method in VirtualKeyboard.java:

public void setInputType(int inputType) {
    if((inputType & TextArea.NUMERIC) == TextArea.NUMERIC || 
            (inputType & TextArea.PHONENUMBER) == TextArea.PHONENUMBER) {
        setInputModeOrder(new String []{NUMBERS_MODE});
        return;
    }
    if((inputType & TextArea.DECIMAL) == TextArea.NUMERIC) {
        setInputModeOrder(new String []{NUMBERS_SYMBOLS_MODE});
        return;
    }
    setInputModeOrder(defaultInputModeOrder);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号