首页 文章

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

提问于
浏览
1

我正在尝试在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 回答

  • 1

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

    Form testForm = new Form(new BorderLayout());
    TextField txt = new TextField(); 
    txt.setConstraint(TextField.NUMERIC);
    
    testForm.add(BorderLayout.NORTH, txt);        
    testForm.show();
    

相关问题