codenameone虚拟键盘没有在Android设备中显示

时间:2016-08-24 13:20:29

标签: codenameone

我正在尝试在TextField聚焦时显示虚拟键盘。当我在Android手机上测试时,会显示其默认键盘,而不是自定义键盘。

    Form testForm = new Form(new BorderLayout());
    TextField txt = new TextField(); 

    String[][] arrOfNumbers = new String[][]{{"1","2","3",}, {"4","5","6",}, {"7","8","9",}, {"0", "00", "$OK$"}};

    VirtualKeyboard virtualKB = new VirtualKeyboard(); 
    virtualKB.addInputMode("NUM_KB", arrOfNumbers);
    virtualKB.setInputModeOrder(new String[]{"NUM_KB"});
    VirtualKeyboard.bindVirtualKeyboard(txt, virtualKB);

    testForm.add(BorderLayout.NORTH, txt);        
    testForm.show();

1 个答案:

答案 0 :(得分:1)

虚拟键盘类是旧版功能的一部分,不应使用。 Codename One使用本机输入,您的代码将使用本机数字输入:

Form testForm = new Form(new BorderLayout());
TextField txt = new TextField(); 
txt.setConstraint(TextField.NUMERIC);

testForm.add(BorderLayout.NORTH, txt);        
testForm.show();