为什么数字约束在LWUIT中的虚拟键盘上不起作用? [英] Why numeric constraint didn't work on Virtual keyboard in LWUIT?
问题描述
我已经测试了很多方法来在TextField中提供数字和密码约束。但它不起作用,请参阅下面的代码。
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"});
以上代码适用于非触控手机。但它不适用于触控手机。所以我设置了 VKB
的输入模式值,并将 TextField
与 VKB绑定
,请参阅此代码。
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 TextField
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
我使用时无法正常工作上面的代码。 VKB
显示通常的格式。这意味着 AlphaNumeric
格式。为什么会出现这样的情况?
VirtualKeyboard.NUMBERS_MODE
not working when I use above code. VKB
showing as usual format. That means AlphaNumeric
format. Why its showing like this?
推荐答案
这是LWUIT的一个错误,感谢你引起我们的注意我会尝试在接下来的几周内为它做出修复。它会更快但我们需要很快飞到JavaOne。
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.
如果你想在本地尝试修复,只需在VirtualKeyboard.java中更新此方法:
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);
}
这篇关于为什么数字约束在LWUIT中的虚拟键盘上不起作用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!