当前位置: 首页>>代码示例>>Java>>正文


Java View.FOCUS_FORWARD属性代码示例

本文整理汇总了Java中android.view.View.FOCUS_FORWARD属性的典型用法代码示例。如果您正苦于以下问题:Java View.FOCUS_FORWARD属性的具体用法?Java View.FOCUS_FORWARD怎么用?Java View.FOCUS_FORWARD使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.view.View的用法示例。


在下文中一共展示了View.FOCUS_FORWARD属性的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onRequestFocusInDescendants

/**
 * When looking for focus in children of a scroll view, need to be a little
 * more careful not to give focus to something that is scrolled off screen.
 * <p/>
 * This is more expensive than the default {@link android.view.ViewGroup}
 * implementation, otherwise this behavior might have been made the default.
 */
@Override
protected boolean onRequestFocusInDescendants(int direction, Rect previouslyFocusedRect) {
    // convert from forward / backward notation to up / down / left / right
    // (ugh).
    if (direction == View.FOCUS_FORWARD) {
        direction = View.FOCUS_DOWN;
    } else if (direction == View.FOCUS_BACKWARD) {
        direction = View.FOCUS_UP;
    }

    final View nextFocus = previouslyFocusedRect == null ?
            FocusFinder.getInstance().findNextFocus(this, null, direction) :
            FocusFinder.getInstance().findNextFocusFromRect(this,
                    previouslyFocusedRect, direction);

    if (nextFocus == null) {
        return false;
    }

    return nextFocus.requestFocus(direction, previouslyFocusedRect);
}
 
开发者ID:tranleduy2000,项目名称:javaide,代码行数:28,代码来源:TwoDScrollView.java

示例2: convertFocusDirectionToLayoutDirectionExpose

/**
 * Converts a focusDirection to orientation.
 *
 * @param focusDirection One of {@link View#FOCUS_UP}, {@link View#FOCUS_DOWN},
 *                       {@link View#FOCUS_LEFT}, {@link View#FOCUS_RIGHT},
 *                       {@link View#FOCUS_BACKWARD}, {@link View#FOCUS_FORWARD}
 *                       or 0 for not applicable
 * @return {@link LayoutState#LAYOUT_START} or {@link LayoutState#LAYOUT_END} if focus direction
 * is applicable to current state, {@link LayoutState#INVALID_LAYOUT} otherwise.
 */
private int convertFocusDirectionToLayoutDirectionExpose(int focusDirection) {
    int orientation = getOrientation();
    switch (focusDirection) {
        case View.FOCUS_BACKWARD:
            return LayoutState.LAYOUT_START;
        case View.FOCUS_FORWARD:
            return LayoutState.LAYOUT_END;
        case View.FOCUS_UP:
            return orientation == VERTICAL ? LayoutState.LAYOUT_START
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_DOWN:
            return orientation == VERTICAL ? LayoutState.LAYOUT_END
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_LEFT:
            return orientation == HORIZONTAL ? LayoutState.LAYOUT_START
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_RIGHT:
            return orientation == HORIZONTAL ? LayoutState.LAYOUT_END
                    : LayoutState.INVALID_LAYOUT;
        default:
            if (DEBUG) {
                Log.d(TAG, "Unknown focus request:" + focusDirection);
            }
            return LayoutState.INVALID_LAYOUT;
    }

}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:37,代码来源:ExposeLinearLayoutManagerEx.java

示例3: convertFocusDirectionToLayoutDirection

/**
 * Converts a focusDirection to orientation.
 *
 * @param focusDirection One of {@link View#FOCUS_UP}, {@link View#FOCUS_DOWN},
 *                       {@link View#FOCUS_LEFT}, {@link View#FOCUS_RIGHT},
 *                       {@link View#FOCUS_BACKWARD}, {@link View#FOCUS_FORWARD}
 *                       or 0 for not applicable
 * @return {@link LayoutState#LAYOUT_START} or {@link LayoutState#LAYOUT_END} if focus direction
 * is applicable to current state, {@link LayoutState#INVALID_LAYOUT} otherwise.
 */
private int convertFocusDirectionToLayoutDirection(int focusDirection) {
    switch (focusDirection) {
        case View.FOCUS_BACKWARD:
            return LayoutState.LAYOUT_START;
        case View.FOCUS_FORWARD:
            return LayoutState.LAYOUT_END;
        case View.FOCUS_UP:
            return mOrientation == VERTICAL ? LayoutState.LAYOUT_START
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_DOWN:
            return mOrientation == VERTICAL ? LayoutState.LAYOUT_END
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_LEFT:
            return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_START
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_RIGHT:
            return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_END
                    : LayoutState.INVALID_LAYOUT;
        default:
            if (DEBUG) {
                Log.d(TAG, "Unknown focus request:" + focusDirection);
            }
            return LayoutState.INVALID_LAYOUT;
    }

}
 
开发者ID:MLNO,项目名称:airgram,代码行数:36,代码来源:StaggeredGridLayoutManager.java

示例4: convertFocusDirectionToLayoutDirection

/**
 * Converts a focusDirection to orientation.
 *
 * @param focusDirection One of {@link View#FOCUS_UP}, {@link View#FOCUS_DOWN},
 *                       {@link View#FOCUS_LEFT}, {@link View#FOCUS_RIGHT},
 *                       {@link View#FOCUS_BACKWARD}, {@link View#FOCUS_FORWARD}
 *                       or 0 for not applicable
 * @return {@link LayoutState#LAYOUT_START} or {@link LayoutState#LAYOUT_END} if focus direction
 * is applicable to current state, {@link LayoutState#INVALID_LAYOUT} otherwise.
 */
int convertFocusDirectionToLayoutDirection(int focusDirection) {
    switch (focusDirection) {
        case View.FOCUS_BACKWARD:
            return LayoutState.LAYOUT_START;
        case View.FOCUS_FORWARD:
            return LayoutState.LAYOUT_END;
        case View.FOCUS_UP:
            return mOrientation == VERTICAL ? LayoutState.LAYOUT_START
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_DOWN:
            return mOrientation == VERTICAL ? LayoutState.LAYOUT_END
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_LEFT:
            return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_START
                    : LayoutState.INVALID_LAYOUT;
        case View.FOCUS_RIGHT:
            return mOrientation == HORIZONTAL ? LayoutState.LAYOUT_END
                    : LayoutState.INVALID_LAYOUT;
        default:
            if (DEBUG) {
                Log.d(TAG, "Unknown focus request:" + focusDirection);
            }
            return LayoutState.INVALID_LAYOUT;
    }

}
 
开发者ID:MLNO,项目名称:airgram,代码行数:36,代码来源:LinearLayoutManager.java

示例5: focusSearch

@Override
public View focusSearch(int direction) {
    switch(direction) {
    case View.FOCUS_FORWARD:
        View v = mDisplay.nextView(this);
        while(!v.isFocusable())
            v = mDisplay.nextView(v);
        return v;
    }
    return super.focusSearch(direction);
}
 
开发者ID:gigabytedevelopers,项目名称:CalcMate,代码行数:11,代码来源:CalculatorEditText.java

示例6: dispatchUnhandledMove

@Override
public boolean dispatchUnhandledMove(View focused, int direction) {
    Log.d(TAG, "dispatchUnhandledMove");
    if (focused != null) {
        cancelShake(focused);

        if (direction == View.FOCUS_FORWARD || direction == View.FOCUS_BACKWARD) {
            if (direction == View.FOCUS_FORWARD) {
                startShake(focused, View.FOCUS_DOWN);
            } else {
                startShake(focused, View.FOCUS_UP);
            }
        } else {
            startShake(focused, direction);
        }
        return true;
    } else {
        return super.dispatchUnhandledMove(focused, direction);
    }

}
 
开发者ID:LikangR,项目名称:TvHelper,代码行数:21,代码来源:FocusBehaviourHandlerView.java

示例7: isPreferredNextFocus

private boolean isPreferredNextFocus(View focused, View next, int direction) {

        if (next == null) {
            return false;
        }
        if (focused == null) {
            return true;
        }

        if (direction == View.FOCUS_FORWARD || direction == View.FOCUS_BACKWARD) {
            if (direction == View.FOCUS_FORWARD) {
                return isPreferredNextFocusAbsolute(focused, next, View.FOCUS_DOWN);
            } else {
                return isPreferredNextFocusAbsolute(focused, next, View.FOCUS_UP);
            }
        } else {
            return isPreferredNextFocusAbsolute(focused, next, direction);
        }

    }
 
开发者ID:LikangR,项目名称:TvHelper,代码行数:20,代码来源:FocusBehaviourHandlerView.java

示例8: focusSearch

@Override
public View focusSearch(int direction) {
    switch(direction) {
    case View.FOCUS_FORWARD:
        return parent.nextView(this);
    }
    return super.focusSearch(direction);
}
 
开发者ID:gigabytedevelopers,项目名称:CalcMate,代码行数:8,代码来源:MatrixEditText.java

示例9: getDistance

/**
 * What is the distance between the source and destination rectangles given
 * the direction of focus navigation between them? The direction basically
 * helps figure out more quickly what is self evident by the relationship
 * between the rects...
 * 
 * @param source
 *            the source rectangle
 * @param dest
 *            the destination rectangle
 * @param direction
 *            the direction
 * @return the distance between the rectangles
 */
public static int getDistance(Rect source, Rect dest, int direction) {

	// TODO: implement this

	int sX, sY; // source x, y
	int dX, dY; // dest x, y
	switch (direction) {
	case View.FOCUS_RIGHT:
		sX = source.right;
		sY = source.top + source.height() / 2;
		dX = dest.left;
		dY = dest.top + dest.height() / 2;
		break;
	case View.FOCUS_DOWN:
		sX = source.left + source.width() / 2;
		sY = source.bottom;
		dX = dest.left + dest.width() / 2;
		dY = dest.top;
		break;
	case View.FOCUS_LEFT:
		sX = source.left;
		sY = source.top + source.height() / 2;
		dX = dest.right;
		dY = dest.top + dest.height() / 2;
		break;
	case View.FOCUS_UP:
		sX = source.left + source.width() / 2;
		sY = source.top;
		dX = dest.left + dest.width() / 2;
		dY = dest.bottom;
		break;
	case View.FOCUS_FORWARD:
	case View.FOCUS_BACKWARD:
		sX = source.right + source.width() / 2;
		sY = source.top + source.height() / 2;
		dX = dest.left + dest.width() / 2;
		dY = dest.top + dest.height() / 2;
		break;
	default:
		throw new IllegalArgumentException("direction must be one of "
				+ "{FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT, "
				+ "FOCUS_FORWARD, FOCUS_BACKWARD}.");
	}
	int deltaX = dX - sX;
	int deltaY = dY - sY;
	return deltaY * deltaY + deltaX * deltaX;
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:61,代码来源:AbsHListView.java

示例10: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // We need to handle focus change within the SimpleMonthView because we are simulating
    // multiple Views. The arrow keys will move between days until there is no space (no
    // day to the left, top, right, or bottom). Focus forward and back jumps out of the
    // SimpleMonthView, skipping over other SimpleMonthViews in the parent ViewPager
    // to the next focusable View in the hierarchy.
    boolean focusChanged = false;
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (event.hasNoModifiers()) {
                focusChanged = moveOneDay(isLayoutRtl());
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (event.hasNoModifiers()) {
                focusChanged = moveOneDay(!isLayoutRtl());
            }
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            if (event.hasNoModifiers()) {
                ensureFocusedDay();
                if (mHighlightedDay > 7) {
                    mHighlightedDay -= 7;
                    focusChanged = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (event.hasNoModifiers()) {
                ensureFocusedDay();
                if (mHighlightedDay <= mDaysInMonth - 7) {
                    mHighlightedDay += 7;
                    focusChanged = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            if (mHighlightedDay != -1) {
                onDayClicked(mHighlightedDay);
                return true;
            }
            break;
        case KeyEvent.KEYCODE_TAB: {
            int focusChangeDirection = 0;
            if (event.hasNoModifiers()) {
                focusChangeDirection = View.FOCUS_FORWARD;
            } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                focusChangeDirection = View.FOCUS_BACKWARD;
            }
            if (focusChangeDirection != 0) {
                final ViewParent parent = getParent();
                // move out of the ViewPager next/previous
                View nextFocus = this;
                do {
                    nextFocus = nextFocus.focusSearch(focusChangeDirection);
                } while (nextFocus != null && nextFocus != this &&
                        nextFocus.getParent() == parent);
                if (nextFocus != null) {
                    nextFocus.requestFocus();
                    return true;
                }
            }
            break;
        }
    }
    if (focusChanged) {
        invalidate();
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:74,代码来源:SimpleMonthView.java


注:本文中的android.view.View.FOCUS_FORWARD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。