Example usage for android.view View setNextFocusForwardId

List of usage examples for android.view View setNextFocusForwardId

Introduction

In this page you can find the example usage for android.view View setNextFocusForwardId.

Prototype

public void setNextFocusForwardId(int nextFocusForwardId) 

Source Link

Document

Sets the id of the view to use when the next focus is #FOCUS_FORWARD .

Usage

From source file:org.videolan.vlc.gui.MyFragment.java

@TargetApi(Build.VERSION_CODES.HONEYCOMB)
@Override/*from w w w .  j av  a  2  s  .  co m*/
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);
}