EditText没有收到TAB键事件 - stock soft vk

Al.*_*Al. 7 tabs android listview keyevent android-edittext

我的应用程序有一个ListViewEditText坐在下面.由于某种原因,TAB键不会触发onKeyListener.我正在处理的所有其他键(DEL,ENTER,DPAD_UP/DOWN/CENTER)都很好.我添加了一个断点dispatchKeyEvent,再次没有运气接收TAB事件.

我的应用程序之前有一个很大TextView的显示文本,在此期间,TAB事件收到了很好.在ListView现在已经取代了TextView.

我完全不知道为什么不再接收TAB事件.这是一个库存Xoom,运行ICS 4.0.4和库存N1,2.3.6.

我用我的相比,对当前版本的代码TextView和大量代码只是为了处理ListView在的地方TextView.除了nextFocusLeftnextFocusRight属性,其他什么都已经改变了的EditText.

编辑:我刚尝试使用Go Keyboard和Hacker的键盘,TAB收到了.看起来这只是一些虚拟键盘

Chu*_*ger 0

我想我可能会看到问题所在。查看 ListView.java 的源代码,有一种机制可以使用在列表项内转移焦点的按键事件。查看该方法之前的注释以及该方法中间的注释块。

/**
 * To avoid horizontal focus searches changing the selected item, we
 * manually focus search within the selected item (as applicable), and
 * prevent focus from jumping to something within another item.
 * @param direction one of {View.FOCUS_LEFT, View.FOCUS_RIGHT}
 * @return Whether this consumes the key event.
 */
private boolean handleHorizontalFocusWithinListItem(int direction) {
    if (direction != View.FOCUS_LEFT && direction != View.FOCUS_RIGHT)  {
        throw new IllegalArgumentException("direction must be one of"
                + " {View.FOCUS_LEFT, View.FOCUS_RIGHT}");
    }

    final int numChildren = getChildCount();
    if (mItemsCanFocus && numChildren > 0 && mSelectedPosition != INVALID_POSITION) {
        final View selectedView = getSelectedView();
        if (selectedView != null && selectedView.hasFocus() &&
                selectedView instanceof ViewGroup) {

            final View currentFocus = selectedView.findFocus();
            final View nextFocus = FocusFinder.getInstance().findNextFocus(
                    (ViewGroup) selectedView, currentFocus, direction);
            if (nextFocus != null) {
                // do the math to get interesting rect in next focus' coordinates
                currentFocus.getFocusedRect(mTempRect);
                offsetDescendantRectToMyCoords(currentFocus, mTempRect);
                offsetRectIntoDescendantCoords(nextFocus, mTempRect);
                if (nextFocus.requestFocus(direction, mTempRect)) {
                    return true;
                }
            }
            // we are blocking the key from being handled (by returning true)
            // if the global result is going to be some other view within this
            // list.  this is to acheive the overall goal of having
            // horizontal d-pad navigation remain in the current item.
            final View globalNextFocus = FocusFinder.getInstance().findNextFocus(
                    (ViewGroup) getRootView(), currentFocus, direction);
            if (globalNextFocus != null) {
                return isViewAncestorOf(globalNextFocus, this);
            }
        }
    }
    return false;
}
Run Code Online (Sandbox Code Playgroud)

单个列表元素中是否有多个可聚焦的项目?如果是这样,此代码将使用 Tab 键。如果是这种情况,那么您可能需要使某些项目无法聚焦或考虑其他设计选项。