Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/342.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 未调用Blackberry touch fone虚拟键盘keyChar方法_Java_Blackberry - Fatal编程技术网

Java 未调用Blackberry touch fone虚拟键盘keyChar方法

Java 未调用Blackberry touch fone虚拟键盘keyChar方法,java,blackberry,Java,Blackberry,我使用一个自定义的编辑字段,它覆盖Keychar方法,如下所示 protected boolean keyChar(char key, int status, int time) { System.out.println(key); Logger.getInstance().logInformationEvent("key char" + String.valueOf(key)); if (key == (char) 27 || (key =

我使用一个自定义的编辑字段,它覆盖Keychar方法,如下所示

          protected boolean keyChar(char key, int status, int time) {
        System.out.println(key);
    Logger.getInstance().logInformationEvent("key char" + String.valueOf(key));

    if (key == (char) 27 || (key == '\b') || (key == (char) 32)) {
        Logger.getInstance().logInformationEvent("key char 1");
        return super.keyChar(key, status, time);
    } else if ((int) key == 13 || (key == '\n') || (key == '1') || (key == '2') || (key == '2') || (key == '3') || (key == '4') || (key == '5')
            || (key == '6') || (key == '7') || (key == '8') || (key == '9') || (key == '0') || (key == ',') || (key == '.') || (key == ';')
            || (key == ':') || (key == '"') || (key == '(') || (key == ')') || (key == '-') || (key == '_') || (key == '+') || (key == '=')
            || (key == '@') || (key == '#') || (key == '$') || (key == '%') || (key == '%') || (key == '}') || (key == '{') || (key == '[')
            || (key == ']') || (key == '*') || (key == '7') || (key == '^') || (key == '>') || (key == '<') || (key == '~') || (key == '`')
            || (key == '!') || (key == '/') || (key == '?')) {
        Logger.getInstance().logInformationEvent("key char 2");
        return true;
    }

    if ((int) key == 39 || (int) key == 92 || (int) key >= 123) {
        Logger.getInstance().logInformationEvent("key char 3");
        return true;
    }

    if (((int) key >= 65 || (int) key <= 90)) {
        Logger.getInstance().logInformationEvent("key char 4");
        return super.keyChar(key, status, time);
    } else if (((int) key >= 97 || (int) key <= 122)) {
        Logger.getInstance().logInformationEvent("key char 5");
        return super.keyChar(key, status, time);
    }
    // ascii code for a to z
    // asc11 fo A to Z

    if (!getText().trim().equals("")) {
        setText(Utility.toUpper(getText()));
    }
    Logger.getInstance().logInformationEvent("key char last");
    return true;



}
受保护的布尔键字符(字符键、int状态、int时间){
系统输出打印项次(键);
Logger.getInstance().logInformationEvent(“key char”+String.valueOf(key));
如果(键==(字符)27 | |(键=='\b')| |(键==(字符)32)){
Logger.getInstance().logInformationEvent(“key char 1”);
返回super.keyChar(键、状态、时间);
}如果((int)key==13 | |(key='\n')| |(key='1')| |(key='2')|(key='2')| |(key='3')| |(key='4')| |(key='5'))
||(key='6')| |(key='7')| |(key='8')| |(key='9')| |(key='0')| |(key==',')| |(key==')| |(key==')
||(键==':')| |(键=')| |(键='(')| |(键='))| |(键='-')| |(键='+)| |(键='+)| |(键=')
||(键=“@”)| |(键=“#”)| |(键=“$”)| |(键=“%”)| |(键=“%”)| |(键=“{”)| |(键=“{”)| |(键=”=“[”)

||(键==']')| |(键=='*')| |(键=='7')| |(键=='^')| |(键=='>')|(key=='我认为解决方案是在自定义编辑字段类中实现
FieldChangeListener
,检查插入的最后一个字符,并围绕插入的字符执行逻辑。我认为这是唯一有意义的解决方案。但是,是的,如果您愿意放弃某个特定字符,那么您需要在EditField中使用
setText()
来更改它,但我认为它将触发另一个
fieldChange
事件,因此请尝试使用布尔检查逻辑来避免它,或者可能是任何其他逻辑,因为您希望避免递归循环

public void fieldChanged(Field field, int context){
    String s = getText();
    char cInserted = s.charAt(s.length()-1);
    //put your logic with character here
}
带有VirtualKeyboard的
keyChar
只能使用ENTER键


我希望它能起作用。如果能起作用,请告诉我们。

嗯,这是一个相当大的问题。正在寻找相同问题的解决方案。