当焦点改变时,我正在使用以下代码显示编辑框的键盘。
no1.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
if(keyCode == 66) {
no2.requestFocus();
}
}
return false;
}
});
no2.setOnKeyListener(new OnKeyListener() {
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
if(keyCode == 66) {
//Log.e("I am inside no2","no2");
no3.requestFocus();
return true;
}
}
return false;
}
});
no2.setOnFocusChangeListener(new View.OnFocusChangeListener() {
public void onFocusChange(View v, boolean hasFocus) {
if (hasFocus) {
Log.e("In","Innnnnn");
InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
imm.showSoftInput(no2, InputMethodManager.SHOW_IMPLICIT);
}
}
});
但是键盘不显示。正在打印日志语句。这意味着它正在进入 focusChanged 方法。任何想法我做错了什么?