本文整理汇总了Java中android.view.KeyEvent.KEYCODE_DPAD_LEFT属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_DPAD_LEFT属性的具体用法?Java KeyEvent.KEYCODE_DPAD_LEFT怎么用?Java KeyEvent.KEYCODE_DPAD_LEFT使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.KEYCODE_DPAD_LEFT属性的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: executeKeyEvent
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例2: run
public void run() {
if (isPressed()) {
if (mCode != 0) {
if (mCode == KeyEvent.KEYCODE_DPAD_LEFT || mCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
sendEvent(KeyEvent.ACTION_UP, KeyEvent.FLAG_SOFT_KEYBOARD |
KeyEvent.FLAG_KEEP_TOUCH_MODE, System.currentTimeMillis(), false);
sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_SOFT_KEYBOARD |
KeyEvent.FLAG_KEEP_TOUCH_MODE, System.currentTimeMillis(), false);
removeCallbacks(mCheckLongPress);
postDelayed(mCheckLongPress, ViewConfiguration.getKeyRepeatDelay());
} else {
sendEvent(KeyEvent.ACTION_DOWN, KeyEvent.FLAG_LONG_PRESS);
sendAccessibilityEvent(AccessibilityEvent.TYPE_VIEW_LONG_CLICKED);
}
} else {
mLongPressConsumed = performLongClick();
}
}
}
示例3: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
//TODO: Should we reverse the keys for RTL? The framework's SeekBar does NOT....
boolean handled = false;
if (isEnabled()) {
int progress = getAnimatedProgress();
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = true;
if (progress <= mMin) break;
animateSetProgress(progress - mKeyProgressIncrement);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = true;
if (progress >= mMax) break;
animateSetProgress(progress + mKeyProgressIncrement);
break;
}
}
return handled || super.onKeyDown(keyCode, event);
}
示例4: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
int increment = selectedColorIndex;
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
case KeyEvent.KEYCODE_MINUS:
increment = Utils.isRTL() ? increment + 1 : increment -1;
if(increment < 0){
return false;
}
setSelectedColorPosition(increment);
return true;
case KeyEvent.KEYCODE_DPAD_RIGHT:
case KeyEvent.KEYCODE_PLUS:
increment = Utils.isRTL() ? increment - 1 : increment + 1;
if(increment >= colors.length){
return false;
}
setSelectedColorPosition(increment);
return true;
}
return super.onKeyDown(keyCode, event);
}
示例5: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_CENTER:
Log.e(TAG, "onKeyDown: ok");
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
Log.e(TAG, "onKeyDown: down");
mViewPager.requestFocus();
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
Log.e(TAG, "onKeyDown: left");
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
Log.e(TAG, "onKeyDown: right");
break;
case KeyEvent.KEYCODE_DPAD_UP:
Log.e(TAG, "onKeyDown: up");
break;
}
return super.onKeyDown(keyCode, event);
}
示例6: executeKeyEvent
/**
* You can call this function yourself to have the scroll view perform
* scrolling from a key event, just as if the event had been dispatched to
* it by the view hierarchy.
*
* @param event The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event) {
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN) {
switch (event.getKeyCode()) {
case KeyEvent.KEYCODE_DPAD_LEFT:
handled = arrowScroll(FOCUS_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
handled = arrowScroll(FOCUS_RIGHT);
break;
case KeyEvent.KEYCODE_TAB:
if (Build.VERSION.SDK_INT >= 11) {
// The focus finder had a bug handling FOCUS_FORWARD and FOCUS_BACKWARD
// before Android 3.0. Ignore the tab key on those devices.
if (KeyEventCompat.hasNoModifiers(event)) {
handled = arrowScroll(FOCUS_FORWARD);
} else if (KeyEventCompat.hasModifiers(event, KeyEvent.META_SHIFT_ON)) {
handled = arrowScroll(FOCUS_BACKWARD);
}
}
break;
}
}
return handled;
}
示例7: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
// If there are no results found, press the left key to reselect the microphone
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT && !mFragment.hasResults()) {
mFragment.focusOnSearch();
}
return super.onKeyDown(keyCode, event);
}
示例8: onKey
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT
|| keyCode == KeyEvent.KEYCODE_PAGE_DOWN || keyCode == KeyEvent.KEYCODE_PAGE_UP) {
// Handle the key event just like a workspace icon would in these cases. In this case,
// it will basically act as if there is a single icon in the top left (so you could
// think of the fullscreen page as a focusable fullscreen widget).
return FocusHelper.handleIconKeyEvent(v, keyCode, event);
}
return false;
}
示例9: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (isEnabled()) {
long positionIncrement = getPositionIncrement();
switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
positionIncrement = -positionIncrement;
// Fall through.
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (scrubIncrementally(positionIncrement)) {
removeCallbacks(stopScrubbingRunnable);
postDelayed(stopScrubbingRunnable, STOP_SCRUBBING_TIMEOUT_MS);
return true;
}
break;
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
if (scrubbing) {
removeCallbacks(stopScrubbingRunnable);
stopScrubbingRunnable.run();
return true;
}
break;
default:
// Do nothing.
}
}
return super.onKeyDown(keyCode, event);
}
示例10: onKeyEvent
public boolean onKeyEvent(KeyEvent event) {
XulLayout layout;
if (_page == null || (layout = _page.getLayout()) == null) {
lastKeyAction = -1;
lastKeyCode = -1;
lastKeyEventView = null;
lastDownHandled = false;
return false;
}
int keyAction = event.getAction();
int keyCode = event.getKeyCode();
XulView focusView = layout.getFocus();
boolean ret = false;
if (keyAction == KeyEvent.ACTION_DOWN) {
if (layout.onKeyEvent(event)) {
lastKeyAction = keyAction;
lastKeyCode = keyCode;
lastKeyEventView = getWeakReference(focusView);
ret = true;
} else switch (keyCode) {
case KeyEvent.KEYCODE_DPAD_LEFT:
ret = layout.moveFocus(XulLayout.FocusDirection.MOVE_LEFT);
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
ret = layout.moveFocus(XulLayout.FocusDirection.MOVE_RIGHT);
break;
case KeyEvent.KEYCODE_DPAD_UP:
ret = layout.moveFocus(XulLayout.FocusDirection.MOVE_UP);
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
ret = layout.moveFocus(XulLayout.FocusDirection.MOVE_DOWN);
break;
case KeyEvent.KEYCODE_DPAD_CENTER:
case KeyEvent.KEYCODE_ENTER:
ret = layout.doClick(actionCallback);
break;
case KeyEvent.KEYCODE_BACK:
ret = _page.popStates();
if (ret) {
XulPage.invokeActionNoPopup(_page, "statesRestored");
}
break;
}
lastDownHandled = ret;
} else if (keyAction == KeyEvent.ACTION_UP) {
XulView xulView = lastKeyEventView == null ? null : lastKeyEventView.get();
if (xulView != focusView) {
ret = lastDownHandled;
} else if (layout.onKeyEvent(event)) {
lastKeyAction = keyAction;
lastKeyCode = keyCode;
lastKeyEventView = getWeakReference(focusView);
ret = true;
} else switch (keyCode) {
default:
ret = lastDownHandled;
break;
}
lastDownHandled = false;
}
lastKeyAction = keyAction;
lastKeyCode = keyCode;
lastKeyEventView = getWeakReference(focusView);
if (ret) {
suspendDrawableWorker();
}
return ret;
}
示例11: executeKeyEvent
/**
* You can call this function yourself to have the scroll view perform scrolling from a key event, just as if the
* event had been dispatched to it by the view hierarchy.
*
* @param event The key event to execute.
* @return Return true if the event was handled, else false.
*/
public boolean executeKeyEvent(KeyEvent event)
{
mTempRect.setEmpty();
boolean handled = false;
if (event.getAction() == KeyEvent.ACTION_DOWN)
{
switch (event.getKeyCode())
{
case KeyEvent.KEYCODE_DPAD_UP:
if (!event.isAltPressed())
{
handled = arrowScroll(View.FOCUS_UP, false);
}
else
{
handled = fullScroll(View.FOCUS_UP, false);
}
break;
case KeyEvent.KEYCODE_DPAD_DOWN:
if (!event.isAltPressed())
{
handled = arrowScroll(View.FOCUS_DOWN, false);
}
else
{
handled = fullScroll(View.FOCUS_DOWN, false);
}
break;
case KeyEvent.KEYCODE_DPAD_LEFT:
if (!event.isAltPressed())
{
handled = arrowScroll(View.FOCUS_LEFT, true);
}
else
{
handled = fullScroll(View.FOCUS_LEFT, true);
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
if (!event.isAltPressed())
{
handled = arrowScroll(View.FOCUS_RIGHT, true);
}
else
{
handled = fullScroll(View.FOCUS_RIGHT, true);
}
break;
}
}
return handled;
}
示例12: 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;
}
示例13: onSuggestionsKey
/**
* React to the user typing while in the suggestions list. First, check for
* action keys. If not handled, try refocusing regular characters into the
* EditText.
*/
private boolean onSuggestionsKey(View v, int keyCode, KeyEvent event) {
// guard against possible race conditions (late arrival after dismiss)
if (mSearchable == null) {
return false;
}
if (mSuggestionsAdapter == null) {
return false;
}
if (event.getAction() == KeyEvent.ACTION_DOWN && KeyEventCompat.hasNoModifiers(event)) {
// First, check for enter or search (both of which we'll treat as a
// "click")
if (keyCode == KeyEvent.KEYCODE_ENTER || keyCode == KeyEvent.KEYCODE_SEARCH
|| keyCode == KeyEvent.KEYCODE_TAB) {
int position = mQueryTextView.getListSelection();
return onItemClicked(position, KeyEvent.KEYCODE_UNKNOWN, null);
}
// Next, check for left/right moves, which we use to "return" the
// user to the edit view
if (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT) {
// give "focus" to text editor, with cursor at the beginning if
// left key, at end if right key
// TODO: Reverse left/right for right-to-left languages, e.g.
// Arabic
int selPoint = (keyCode == KeyEvent.KEYCODE_DPAD_LEFT) ? 0 : mQueryTextView
.length();
mQueryTextView.setSelection(selPoint);
mQueryTextView.setListSelection(0);
mQueryTextView.clearListSelection();
ensureImeVisible(mQueryTextView, true);
return true;
}
// Next, check for an "up and out" move
if (keyCode == KeyEvent.KEYCODE_DPAD_UP && 0 == mQueryTextView.getListSelection()) {
// TODO: restoreUserQuery();
// let ACTV complete the move
return false;
}
// Next, check for an "action key"
// TODO SearchableInfo.ActionKeyInfo actionKey = mSearchable.findActionKey(keyCode);
// TODO if ((actionKey != null)
// TODO && ((actionKey.getSuggestActionMsg() != null) || (actionKey
// TODO .getSuggestActionMsgColumn() != null))) {
// TODO // launch suggestion using action key column
// TODO int position = mQueryTextView.getListSelection();
// TODO if (position != ListView.INVALID_POSITION) {
// TODO Cursor c = mSuggestionsAdapter.getCursor();
// TODO if (c.moveToPosition(position)) {
// TODO final String actionMsg = getActionKeyMessage(c, actionKey);
// TODO if (actionMsg != null && (actionMsg.length() > 0)) {
// TODO return onItemClicked(position, keyCode, actionMsg);
// TODO }
// TODO }
// TODO }
// TODO }
}
return false;
}