Java Code Examples for android.view.View#getNextFocusRightId()

The following examples show how to use android.view.View#getNextFocusRightId() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may want to check out the right sidebar which shows the related API usage.
Example 1
Source Project: ExoMedia   File: VideoControlsLeanback.java    License: Apache License 2.0 6 votes vote down vote up
/**
 * Focuses the next visible view specified in the <code>view</code>
 *
 * @param view The view to find the next focus for
 */
protected void focusNext(View view) {
    int nextId = view.getNextFocusRightId();
    if (nextId == NO_ID) {
        return;
    }

    View nextView = findViewById(nextId);
    if (nextView.getVisibility() != View.VISIBLE) {
        focusNext(nextView);
        return;
    }

    nextView.requestFocus();
    currentFocus = nextView;
    buttonFocusChangeListener.onFocusChange(nextView, true);
}
 
Example 2
Source Project: DevUtils   File: ViewUtils.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * 向右移动焦点时, 下一个获取焦点的 View id
 * @param view {@link View}
 * @return 向右移动焦点时, 下一个获取焦点的 View id
 */
public static int getNextFocusRightId(final View view) {
    if (view != null) {
        return view.getNextFocusRightId();
    }
    return 0;
}
 
Example 3
Source Project: VCL-Android   File: MainActivity.java    License: Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    //Filter for LG devices, see https://code.google.com/p/android/issues/detail?id=78154
    if ((keyCode == KeyEvent.KEYCODE_MENU) &&
            (Build.VERSION.SDK_INT <= 16) &&
            (Build.MANUFACTURER.compareTo("LGE") == 0)) {
        openOptionsMenu();
        return true;
    }
    View v = getCurrentFocus();
    if (v == null)
        return super.onKeyUp(keyCode, event);
    if ((mActionBarIconId == -1) &&
        (v.getId() == -1)  &&
        (v.getNextFocusDownId() == -1) &&
        (v.getNextFocusUpId() == -1) &&
        (v.getNextFocusLeftId() == -1) &&
        (v.getNextFocusRightId() == -1)) {
        mActionBarIconId = Util.generateViewId();
        v.setId(mActionBarIconId);
        v.setNextFocusUpId(mActionBarIconId);
        v.setNextFocusDownId(mActionBarIconId);
        v.setNextFocusLeftId(mActionBarIconId);
        v.setNextFocusRightId(R.id.ml_menu_search);
        if (AndroidUtil.isHoneycombOrLater())
            v.setNextFocusForwardId(mActionBarIconId);
        if (findViewById(R.id.ml_menu_search) != null)
            findViewById(R.id.ml_menu_search).setNextFocusLeftId(mActionBarIconId);
    }
    return super.onKeyUp(keyCode, event);
}