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


Java View.FOCUS_BACKWARD属性代码示例

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


在下文中一共展示了View.FOCUS_BACKWARD属性的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: 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

示例6: 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

示例7: onTakeFocus

@Override
public void onTakeFocus(TextView view, Spannable text, int dir) {
    Selection.removeSelection(text);

    if ((dir & View.FOCUS_BACKWARD) != 0) {
        text.setSpan(FROM_BELOW, 0, 0, Spannable.SPAN_POINT_POINT);
    } else {
        text.removeSpan(FROM_BELOW);
    }
}
 
开发者ID:l465659833,项目名称:Bigbang,代码行数:10,代码来源:CountLinkMovementMethod.java

示例8: focusSearch

@Override
public View focusSearch(int direction) {
    if (direction == View.FOCUS_BACKWARD
            && mUrlBarDelegate.getCurrentTab().getView() != null) {
        return mUrlBarDelegate.getCurrentTab().getView();
    } else {
        return super.focusSearch(direction);
    }
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:9,代码来源:UrlBar.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_BACKWARD属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。