當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.KEYCODE_DPAD_DOWN屬性代碼示例

本文整理匯總了Java中android.view.KeyEvent.KEYCODE_DPAD_DOWN屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.KEYCODE_DPAD_DOWN屬性的具體用法?Java KeyEvent.KEYCODE_DPAD_DOWN怎麽用?Java KeyEvent.KEYCODE_DPAD_DOWN使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.KEYCODE_DPAD_DOWN屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    //click mapping
    if(TVUtils.isOKKey(keyCode) &&ocl!=null) {
        this.ocl.onClick(this);
        return true;
    }
    //handle focus on dialog
    else if ((keyCode == KeyEvent.KEYCODE_DPAD_DOWN||keyCode == KeyEvent.KEYCODE_DPAD_UP)&&this.ofol!=null) {
        View v = findFocus().focusSearch(keyCode == KeyEvent.KEYCODE_DPAD_DOWN?FOCUS_DOWN:FOCUS_UP);
        if(v instanceof TVMenuSeparator){
        	v = v.focusSearch(keyCode == KeyEvent.KEYCODE_DPAD_DOWN?FOCUS_DOWN:FOCUS_UP);          	
        }
        if(isViewInCard(v)){
        	v.requestFocus();
        	return true;
        }
        else if(this.ofol!=null)
        	return this.ofol.onFocusOut(keyCode);
    }
    return false;

}
 
開發者ID:archos-sa,項目名稱:aos-Video,代碼行數:23,代碼來源:TVCardView.java

示例2: onKeyDown

/**
 * Handles key events in the game. Update the direction our snake is traveling based on the
 * DPAD.
 *
 */
@Override
public boolean onKeyDown(int keyCode, KeyEvent msg) {

    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_UP:
            mSnakeView.moveSnake(MOVE_UP);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            mSnakeView.moveSnake(MOVE_RIGHT);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            mSnakeView.moveSnake(MOVE_DOWN);
            break;
        case KeyEvent.KEYCODE_DPAD_LEFT:
            mSnakeView.moveSnake(MOVE_LEFT);
            break;
    }

    return super.onKeyDown(keyCode, msg);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:25,代碼來源:Snake.java

示例3: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        switch (event.getKeyCode()) {
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                lineByLineMoveTo(1);
                return true;
            case KeyEvent.KEYCODE_DPAD_LEFT:
                lineByLineMoveTo(-1);
                return true;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                verticalDpadScroll(1);
                return true;
            case KeyEvent.KEYCODE_DPAD_UP:
                verticalDpadScroll(-1);
                return true;
        }
    }
    return super.dispatchKeyEvent(event);
}
 
開發者ID:lidong1665,項目名稱:AndroidPDF,代碼行數:20,代碼來源:DocumentView.java

示例4: playSoundEffect

/**
 * Helper method to be used for playing sound effects.
 */
@Thunk private static void playSoundEffect(int keyCode, View v) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_PAGE_DOWN:
        case KeyEvent.KEYCODE_MOVE_END:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN);
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_PAGE_UP:
        case KeyEvent.KEYCODE_MOVE_HOME:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP);
            break;
        default:
            break;
    }
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:25,代碼來源:FocusHelper.java

示例5: playSoundEffect

/**
 * Helper method to be used for playing sound effects.
 */
@Thunk static void playSoundEffect(int keyCode, View v) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_LEFT);
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_RIGHT);
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_PAGE_DOWN:
        case KeyEvent.KEYCODE_MOVE_END:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_DOWN);
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_PAGE_UP:
        case KeyEvent.KEYCODE_MOVE_HOME:
            v.playSoundEffect(SoundEffectConstants.NAVIGATION_UP);
            break;
        default:
            break;
    }
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:25,代碼來源:FocusHelper.java

示例6: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    final int keyCode = event.getKeyCode();
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            removeAllCallbacks();
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_DPAD_UP:
            if (!mHasSelectorWheel) {
                break;
            }
            switch (event.getAction()) {
                case KeyEvent.ACTION_DOWN:
                    if (mWrapSelectorWheel || ((keyCode == KeyEvent.KEYCODE_DPAD_DOWN)
                            ? getValue() < getMaxValue() : getValue() > getMinValue())) {
                        requestFocus();
                        mLastHandledDownDpadKeyCode = keyCode;
                        removeAllCallbacks();
                        if (mFlingScroller.isFinished()) {
                            changeValueByOne(keyCode == KeyEvent.KEYCODE_DPAD_DOWN);
                        }
                        return true;
                    }
                    break;
                case KeyEvent.ACTION_UP:
                    if (mLastHandledDownDpadKeyCode == keyCode) {
                        mLastHandledDownDpadKeyCode = -1;
                        return true;
                    }
                    break;
            }
    }
    return super.dispatchKeyEvent(event);
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:36,代碼來源:NumberPicker.java

示例7: shouldConsume

/**
 * Returns true only if this utility class handles the key code.
 */
public static boolean shouldConsume(int keyCode) {
    return (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
            keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN ||
            keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END ||
            keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN);
}
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:9,代碼來源:FocusLogic.java

示例8: shouldConsume

/**
 * Returns true only if this utility class handles the key code.
 */
public static boolean shouldConsume(int keyCode) {
    return (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
            keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN ||
            keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END ||
            keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN ||
            keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL);
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:10,代碼來源:FocusLogic.java

示例9: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (mOnInterceptListener != null && mOnInterceptListener.onIntercept(event)) {
        return true;
    }
    boolean result = super.dispatchKeyEvent(event);
    View focusView = this.getFocusedChild();
    if (focusView == null) {
        return result;
    } else {
        // TODO: 2017-11-3 解決不同viewType的item滑動
        int dy = 0;
        int dx = 0;
        if (getChildCount() > 0) {
            View firstView = this.getChildAt(0);
            dy = firstView.getHeight();
            dx = firstView.getWidth();
        }
        if (event.getAction() == KeyEvent.ACTION_UP
                && keyCodeOfDPAD(event)) {
            return true;
        } else {
            switch (event.getKeyCode()) {
                case KeyEvent.KEYCODE_DPAD_RIGHT:
                    return findNextFocusView(focusView, new Point(dx, 0), View.FOCUS_RIGHT);
                case KeyEvent.KEYCODE_DPAD_LEFT:
                    return findNextFocusView(focusView, new Point(-dx, 0), View.FOCUS_LEFT);
                case KeyEvent.KEYCODE_DPAD_DOWN:
                    return findNextFocusView(focusView, new Point(0, dy), View.FOCUS_DOWN);
                case KeyEvent.KEYCODE_DPAD_UP:
                    return findNextFocusView(focusView, new Point(0, -dy), View.FOCUS_UP);
            }
        }
    }


    return result;
}
 
開發者ID:kevinhqf,項目名稱:TVRecyclerView,代碼行數:38,代碼來源:TVRecyclerView.java

示例10: isNavigationKey

public static boolean isNavigationKey(KeyEvent event) {
	int keyCode = event.getKeyCode();
	return keyCode == KeyEvent.KEYCODE_DPAD_DOWN ||
		keyCode == KeyEvent.KEYCODE_DPAD_UP ||
		keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
		keyCode == KeyEvent.KEYCODE_DPAD_LEFT;
}
 
開發者ID:MikaGuraN,項目名稱:HL4A,代碼行數:7,代碼來源:KeysInterpreter.java

示例11: handleKeyActionUp

private boolean handleKeyActionUp(View v, int keyCode, KeyEvent event) {
    if(isInterruptOnKeyActionUp(v, keyCode, event)){
        return true;
    }
    switch (keyCode){
        case KeyEvent.KEYCODE_DPAD_UP:
            PLog.d(TAG,"onKeyActionUp : dpad up");
            return onKeyActionUpDpadUp(v, keyCode, event);

        case KeyEvent.KEYCODE_DPAD_DOWN:
            PLog.d(TAG,"onKeyActionUp : dpad down");
            return onKeyActionUpDpadDown(v, keyCode, event);

        case KeyEvent.KEYCODE_DPAD_LEFT:
            PLog.d(TAG,"onKeyActionUp : dpad left");
            return onKeyActionUpDpadLeft(v, keyCode, event);

        case KeyEvent.KEYCODE_DPAD_RIGHT:
            PLog.d(TAG,"onKeyActionUp : dpad right");
            return onKeyActionUpDpadRight(v, keyCode, event);

        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            PLog.d(TAG,"onKeyActionUp : dpad enter");
            return onKeyActionUpDpadEnter(v, keyCode, event);

        case KeyEvent.KEYCODE_BACK:
            PLog.d(TAG,"onKeyActionUp : dpad back");
            return onKeyActionUpDpadBack(v, keyCode, event);

        case KeyEvent.KEYCODE_MENU:
            PLog.d(TAG,"onKeyActionUp : dpad menu");
            return onKeyActionUpDpadMenu(v, keyCode, event);
    }
    return false;
}
 
開發者ID:jiajunhui,項目名稱:PlayerBase,代碼行數:36,代碼來源:BaseFocusCover.java

示例12: executeKeyEvent

@Override
public boolean executeKeyEvent(KeyEvent event) {
    // Ignore all key events except arrow keys and spacebar. Otherwise, the ScrollView consumes
    // unwanted events (including the hardware menu button and app-level keyboard shortcuts).
    // http://crbug.com/308322
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_DPAD_DOWN:
        case KeyEvent.KEYCODE_SPACE:
            return super.executeKeyEvent(event);
        default:
            return false;
    }
}
 
開發者ID:rkshuai,項目名稱:chromium-for-android-56-debug-video,代碼行數:14,代碼來源:NewTabPageScrollView.java

示例13: onKeyDown

public boolean onKeyDown(int keyCode, KeyEvent event) {
    // Handle DPad keys and fire button on initial down but not on
    // auto-repeat.
    boolean handled = false;
    if (event.getRepeatCount() == 0) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_DPAD_LEFT:
                setHeadingX(-1);
                mDPadState |= DPAD_STATE_LEFT;
                handled = true;
                break;
            case KeyEvent.KEYCODE_DPAD_RIGHT:
                setHeadingX(1);
                mDPadState |= DPAD_STATE_RIGHT;
                handled = true;
                break;
            case KeyEvent.KEYCODE_DPAD_UP:
                setHeadingY(-1);
                mDPadState |= DPAD_STATE_UP;
                handled = true;
                break;
            case KeyEvent.KEYCODE_DPAD_DOWN:
                setHeadingY(1);
                mDPadState |= DPAD_STATE_DOWN;
                handled = true;
                break;
            default:
                if (isFireKey(keyCode)) {
                    fire();
                    handled = true;
                }
                break;
        }
    }
    return handled;
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:36,代碼來源:GameView.java

示例14: extOnKeyEvent

@Override
public boolean extOnKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
        case KeyEvent.KEYCODE_DPAD_RIGHT:
        case KeyEvent.KEYCODE_DPAD_UP:
        case KeyEvent.KEYCODE_DPAD_DOWN:
            return dispatchKeyEvent(event);
    }
    return false;
}
 
開發者ID:starcor-company,項目名稱:starcor.xul,代碼行數:12,代碼來源:XulExt_ExternalEditBox.java

示例15: handleKeyEvent

public static int handleKeyEvent(int keyCode, int [][] map, int iconIdx, int pageIndex,
        int pageCount, boolean isRtl) {

    int cntX = map == null ? -1 : map.length;
    int cntY = map == null ? -1 : map[0].length;

    if (DEBUG) {
        Log.v(TAG, String.format(
                "handleKeyEvent START: cntX=%d, cntY=%d, iconIdx=%d, pageIdx=%d, pageCnt=%d",
                cntX, cntY, iconIdx, pageIndex, pageCount));
    }

    int newIndex = NOOP;
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, -1 /*increment*/, isRtl);
            if (!isRtl && newIndex == NOOP && pageIndex > 0) {
                newIndex = PREVIOUS_PAGE_RIGHT_COLUMN;
            } else if (isRtl && newIndex == NOOP && pageIndex < pageCount - 1) {
                newIndex = NEXT_PAGE_RIGHT_COLUMN;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            newIndex = handleDpadHorizontal(iconIdx, cntX, cntY, map, 1 /*increment*/, isRtl);
            if (!isRtl && newIndex == NOOP && pageIndex < pageCount - 1) {
                newIndex = NEXT_PAGE_LEFT_COLUMN;
            } else if (isRtl && newIndex == NOOP && pageIndex > 0) {
                newIndex = PREVIOUS_PAGE_LEFT_COLUMN;
            }
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            newIndex = handleDpadVertical(iconIdx, cntX, cntY, map, 1  /*increment*/);
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            newIndex = handleDpadVertical(iconIdx, cntX, cntY, map, -1  /*increment*/);
            break;
        case KeyEvent.KEYCODE_MOVE_HOME:
            newIndex = handleMoveHome();
            break;
        case KeyEvent.KEYCODE_MOVE_END:
            newIndex = handleMoveEnd();
            break;
        case KeyEvent.KEYCODE_PAGE_DOWN:
            newIndex = handlePageDown(pageIndex, pageCount);
            break;
        case KeyEvent.KEYCODE_PAGE_UP:
            newIndex = handlePageUp(pageIndex);
            break;
        default:
            break;
    }

    if (DEBUG) {
        Log.v(TAG, String.format("handleKeyEvent FINISH: index [%d -> %s]",
                iconIdx, getStringIndex(newIndex)));
    }
    return newIndex;
}
 
開發者ID:michelelacorte,項目名稱:FlickLauncher,代碼行數:58,代碼來源:FocusLogic.java


注:本文中的android.view.KeyEvent.KEYCODE_DPAD_DOWN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。