在EditText的onKeyDown()方法中,手动处理dpadUp/dpadDown事件。在处理dpadUp时,使用View.focusSearch(View.FOCUS_UP)找到上方的视图;在处理dpadDown时,使用View.focusSearch(View.FOCUS_DOWN)找到下方的视图,并使用view.requestFocus()将焦点集中到该视图上。
示例代码:
@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_DPAD_UP) { View upView = this.focusSearch(View.FOCUS_UP); upView.requestFocus(); return true; } else if (keyCode == KeyEvent.KEYCODE_DPAD_DOWN) { View downView = this.focusSearch(View.FOCUS_DOWN); downView.requestFocus(); return true; } return super.onKeyDown(keyCode, event); }