Android 切换焦点使键盘消失

Android switching focus makes keyboard disappear

我想在按下 KEYCODE_DEL 按钮时在两个 EditText 视图之间切换。

我的代码有效,它确实关注前面的 EditText,但是当它这样做时,键盘消失,光标位于 EditText 中的实际文本之前。

为了更生动,当焦点切换时,EditText看起来像这样:

|23 其中 | 是光标位置,键盘被隐藏。

这是我的代码:

if(event.getKeyCode() == KeyEvent.KEYCODE_DEL){
        super.dispatchKeyEvent(event);
        focusPreviousET();
        return true;
    }
else{
    super.dispatchKeyEvent(event);
    check();
    return true;
 }

private void focusPreviousET() {

    String sId = getId(getCurrentFocus());

    Identification id = new Identification(sId);

    etX = getETFromResource(id);

    if(isEmpty(etX)){
        etX.setEnabled(false);
        id.previousId();
        etX = getETFromResource(id);
        etX.requestFocus();
    }
}
public void check(){
       etX  = (EditText) getCurrentFocus();
    if(etX.getText().toString().length()==2){
        focusNextFreeET();
    }
}

另外 check() 方法不起作用,我不知道为什么...方法 focusNextFreeET() 在其他情况下有效,但在这里不行。

有什么建议吗?

编辑

忘了说了,EditText填22,31,10之类的数字时,光标实际上是在末尾,而数字前面有0时,光标是在开头它,比如 01,02 等...在这两种情况下,键盘都是隐藏的。

聚焦下一个项目后使用这些行打开键盘

InputMethodManager inputMethodManager=(InputMethodManager)getSystemService(Context.INPUT_METHOD_SERVICE);
inputMethodManager.toggleSoftInputFromWindow(yourEditText.getApplicationWindowToken(), InputMethodManager.SHOW_FORCED, 0);