0

我们在我的 Android 屏幕上的两个文本框之间有微调器。当焦点位于第一个文本框并且我从软键单击下一步时,它会直接移动到下一个文本框而不是微调器。

4

1 回答 1

2

使用这种方式:

    firsttextbox.setNextFocusDownId(R.id.edtemail);
    spinner.setNextFocusDownId(R.id.sp1);
    secondtextbox.setNextFocusDownId(R.id.stc);

 firsttextbox.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                    && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // Perform action on Enter key press
                firsttextbox.clearFocus();
                spinner.requestFocus();
                return true;
            }
            return false;
        }
    });
    spinner.setOnKeyListener(new OnKeyListener() {

        public boolean onKey(View v, int keyCode, KeyEvent event) {
            // If the event is a key-down event on the "enter" button
            if ((event.getAction() == KeyEvent.ACTION_DOWN)
                    && (keyCode == KeyEvent.KEYCODE_ENTER)) {
                // Perform action on Enter key press
                spinner.clearFocus();
                secondtextbox.requestFocus();
                return true;
            }
            return false;
        }
    });
于 2013-09-19T07:10:24.833 回答