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


Java View.FOCUS_LEFT属性代码示例

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


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

示例1: dispatchUnhandledMove

@Override
public boolean dispatchUnhandledMove(View focused, int direction) {
    if (super.dispatchUnhandledMove(focused, direction)) {
        return true;
    }

    if (mIsRtl) {
        if (direction == View.FOCUS_LEFT) {
            direction = View.FOCUS_RIGHT;
        } else if (direction == View.FOCUS_RIGHT) {
            direction = View.FOCUS_LEFT;
        }
    }
    if (direction == View.FOCUS_LEFT) {
        if (getCurrentPage() > 0) {
            snapToPage(getCurrentPage() - 1);
            return true;
        }
    } else if (direction == View.FOCUS_RIGHT) {
        if (getCurrentPage() < getPageCount() - 1) {
            snapToPage(getCurrentPage() + 1);
            return true;
        }
    }
    return false;
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:26,代码来源:PagedView.java

示例2: addFocusables

@Override
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
    if (getDescendantFocusability() == FOCUS_BLOCK_DESCENDANTS) {
        return;
    }

    // XXX-RTL: This will be fixed in a future CL
    if (mCurrentPage >= 0 && mCurrentPage < getPageCount()) {
        getPageAt(mCurrentPage).addFocusables(views, direction, focusableMode);
    }
    if (direction == View.FOCUS_LEFT) {
        if (mCurrentPage > 0) {
            getPageAt(mCurrentPage - 1).addFocusables(views, direction, focusableMode);
        }
    } else if (direction == View.FOCUS_RIGHT){
        if (mCurrentPage < getPageCount() - 1) {
            getPageAt(mCurrentPage + 1).addFocusables(views, direction, focusableMode);
        }
    }
}
 
开发者ID:enricocid,项目名称:LaunchEnr,代码行数:20,代码来源:PagedView.java

示例3: addFocusables

@Override
public void addFocusables(ArrayList<View> views, int direction, int focusableMode) {
    // XXX-RTL: This will be fixed in a future CL
    if (mCurrentPage >= 0 && mCurrentPage < getPageCount()) {
        getPageAt(mCurrentPage).addFocusables(views, direction, focusableMode);
    }
    if (direction == View.FOCUS_LEFT) {
        if (mCurrentPage > 0) {
            getPageAt(mCurrentPage - 1).addFocusables(views, direction, focusableMode);
        }
    } else if (direction == View.FOCUS_RIGHT){
        if (mCurrentPage < getPageCount() - 1) {
            getPageAt(mCurrentPage + 1).addFocusables(views, direction, focusableMode);
        }
    }
}
 
开发者ID:michelelacorte,项目名称:FlickLauncher,代码行数:16,代码来源:PagedView.java

示例4: isPreferredNextFocusAbsolute

/**
 * Logic taken from FocusSearch#isCandidate
 */
private boolean isPreferredNextFocusAbsolute(View focused, View next, int direction) {

    int[] location = getLocation(focused);
    int[] location2 = getLocation(next);
    mTempRect.set(location[0], location[1], location[0] + focused.getWidth(), location[1] + focused.getHeight());
    mTempRect2.set(location2[0], location2[1], location2[0] + next.getWidth(), location2[1] + next.getHeight());

    switch (direction) {
        case View.FOCUS_LEFT:
            return mTempRect.left >= mTempRect2.right;
        case View.FOCUS_RIGHT:
            return mTempRect.right <= mTempRect2.left;
        case View.FOCUS_UP:
            return mTempRect.top >= mTempRect2.bottom;
        case View.FOCUS_DOWN:
            return mTempRect.bottom <= mTempRect2.top;
    }
    throw new IllegalArgumentException("direction must be absolute. received:" + direction);
}
 
开发者ID:LikangR,项目名称:TvHelper,代码行数:22,代码来源:FocusBehaviourHandlerView.java

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

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

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

示例8: arrowScroll

/**
 * 获得滑动的方向
 */
public boolean arrowScroll(int direction) {
    View currentFocused = findFocus();
    if (currentFocused == this) currentFocused = null;

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused,
            direction);
    if (nextFocused != null && nextFocused != currentFocused) {
        if (direction == View.FOCUS_LEFT) {
            handled = nextFocused.requestFocus();
        } else if (direction == View.FOCUS_RIGHT) {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page right.
            if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) {
                handled = pageRight();
            } else {
                handled = nextFocused.requestFocus();
            }
        }
    } else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) {
        // Trying to move left and nothing there; try to page.
        handled = pageLeft();
    } else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) {
        // Trying to move right and nothing there; try to page.
        handled = pageRight();
    }
    if (handled) {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}
 
开发者ID:Datatellit,项目名称:xlight_android_native,代码行数:35,代码来源:CustomViewAbove.java

示例9: arrowScroll

public boolean arrowScroll(int direction) {
	View currentFocused = findFocus();
	if (currentFocused == this) currentFocused = null;

	boolean handled = false;

	View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused,
			direction);
	if (nextFocused != null && nextFocused != currentFocused) {
		if (direction == View.FOCUS_LEFT) {
			handled = nextFocused.requestFocus();
		} else if (direction == View.FOCUS_RIGHT) {
			// If there is nothing to the right, or this is causing us to
			// jump to the left, then what we really want to do is page right.
			if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft()) {
				handled = pageRight();
			} else {
				handled = nextFocused.requestFocus();
			}
		}
	} else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD) {
		// Trying to move left and nothing there; try to page.
		handled = pageLeft();
	} else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD) {
		// Trying to move right and nothing there; try to page.
		handled = pageRight();
	}
	if (handled) {
		playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
	}
	return handled;
}
 
开发者ID:QuixomTech,项目名称:WeatherStream,代码行数:32,代码来源:CustomViewAbove.java

示例10: calcOffsetToNextView

/**
 * Calculates position offset.
 *
 * @param direction regular {@code View.FOCUS_*}.
 * @return position offset according to {@code direction}.
 */
protected int calcOffsetToNextView(int direction)
{
    int spanCount = getSpanCount();
    int orientation = getOrientation();
    
    if (orientation == VERTICAL)
    {
        switch (direction)
        {
            case View.FOCUS_DOWN:
                return spanCount;
            case View.FOCUS_UP:
                return -spanCount;
            case View.FOCUS_RIGHT:
                return 1;
            case View.FOCUS_LEFT:
                return -1;
        }
    }
    else if (orientation == HORIZONTAL)
    {
        switch (direction)
        {
            case View.FOCUS_DOWN:
                return 1;
            case View.FOCUS_UP:
                return -1;
            case View.FOCUS_RIGHT:
                return spanCount;
            case View.FOCUS_LEFT:
                return -spanCount;
        }
    }
    
    return 0;
}
 
开发者ID:Dreamxiaoxuan,项目名称:AndroidTvDemo,代码行数:42,代码来源:FocusGridLayoutManager.java

示例11: 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
 */
static int getDistance(Rect source, Rect dest, int direction) {
    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;
        default:
            throw new IllegalArgumentException("direction must be one of "
                    + "{FOCUS_UP, FOCUS_DOWN, FOCUS_LEFT, FOCUS_RIGHT}.");
    }
    int deltaX = dX - sX;
    int deltaY = dY - sY;
    return deltaY * deltaY + deltaX * deltaX;
}
 
开发者ID:Shmilyz,项目名称:Swap,代码行数:46,代码来源:PLA_AbsListView.java

示例12: arrowScroll

public boolean arrowScroll(int direction)
{
    View currentFocused = findFocus();
    if (currentFocused == this)
    {
        currentFocused = null;
    }

    boolean handled = false;

    View nextFocused = FocusFinder.getInstance().findNextFocus(this, currentFocused,
            direction);
    if (nextFocused != null && nextFocused != currentFocused)
    {
        if (direction == View.FOCUS_LEFT)
        {
            handled = nextFocused.requestFocus();
        }
        else if (direction == View.FOCUS_RIGHT)
        {
            // If there is nothing to the right, or this is causing us to
            // jump to the left, then what we really want to do is page right.
            if (currentFocused != null && nextFocused.getLeft() <= currentFocused.getLeft())
            {
                handled = pageRight();
            }
            else
            {
                handled = nextFocused.requestFocus();
            }
        }
    }
    else if (direction == FOCUS_LEFT || direction == FOCUS_BACKWARD)
    {
        // Trying to move left and nothing there; try to page.
        handled = pageLeft();
    }
    else if (direction == FOCUS_RIGHT || direction == FOCUS_FORWARD)
    {
        // Trying to move right and nothing there; try to page.
        handled = pageRight();
    }
    if (handled)
    {
        playSoundEffect(SoundEffectConstants.getContantForFocusDirection(direction));
    }
    return handled;
}
 
开发者ID:HueToYou,项目名称:ChatExchange-old,代码行数:48,代码来源:CustomViewAbove.java


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