我正在尝试将焦点移动到下一个字段/按钮,但它似乎不想工作。这是我现在拥有的:
@Override
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_TAB)
{
//move down here once I figure it out..
mEmailvalue.getNextFocusDownId();
return true;
}
return super.dispatchKeyEvent(event);
}
答案 0 :(得分:2)
试试这个:
public boolean dispatchKeyEvent(KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_TAB && event.getAction()==KeyEvent.ACTION_DOWN) {
View currentFocus = getCurrentFocus();
if (currentFocus!=null) {
View next = currentFocus.focusSearch(View.FOCUS_DOWN);
if (next!=null) {
next.requestFocus();
}
}
return true;
}
return super.dispatchKeyEvent(event);
}