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


Java KeyEvent.ACTION_DOWN属性代码示例

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


在下文中一共展示了KeyEvent.ACTION_DOWN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:33,代码来源:BaseViewPager.java

示例2: createInputConnection

public InputConnection createInputConnection(InputConnection base) {
    return base == null ? null : new InputConnectionWrapper(base, true) {

        @Override
        public boolean sendKeyEvent(KeyEvent event) {
            // TODO: this could be improved by working even when we are not empty.
            // The behavior should be 'delete isLast character from mPre'.
            // In that case, we should check also that getSelectionStart() == 0.
            if (!isFirst() && mView.getText().length() == 0 &&
                    event.getAction() == KeyEvent.ACTION_DOWN &&
                    event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
                removeFromChain(mView);
                return false;
            }
            return super.sendKeyEvent(event);
        }
    };
}
 
开发者ID:natario1,项目名称:ViewPrinter,代码行数:18,代码来源:AutoSplitTextHelper.java

示例3: dispatchKeyEvent

/**
 * Called to process key events.  You can override this to intercept all
 * key events before they are dispatched to the window.  Be sure to call
 * this implementation for key events that should be handled normally.
 *
 * @param event The key event.
 *
 * @return boolean Return true if this event was consumed.
 */
public boolean dispatchKeyEvent(KeyEvent event) {
    onUserInteraction();

    // Let action bars open menus in response to the menu key prioritized over
    // the window handling it
    final int keyCode = event.getKeyCode();
    if (keyCode == KeyEvent.KEYCODE_MENU &&
            mActionBar != null && mActionBar.onMenuKeyEvent(event)) {
        return true;
    } else if (event.isCtrlPressed() &&
            event.getUnicodeChar(event.getMetaState() & ~KeyEvent.META_CTRL_MASK) == '<') {
        // Capture the Control-< and send focus to the ActionBar
        final int action = event.getAction();
        if (action == KeyEvent.ACTION_DOWN) {
            final ActionBar actionBar = getActionBar();
            if (actionBar != null && actionBar.isShowing() && actionBar.requestFocus()) {
                mEatKeyUpEvent = true;
                return true;
            }
        } else if (action == KeyEvent.ACTION_UP && mEatKeyUpEvent) {
            mEatKeyUpEvent = false;
            return true;
        }
    }

    Window win = getWindow();
    if (win.superDispatchKeyEvent(event)) {
        return true;
    }
    View decor = mDecor;
    if (decor == null) decor = win.getDecorView();
    return event.dispatch(this, decor != null
            ? decor.getKeyDispatcherState() : null, this);
}
 
开发者ID:JessYanCoding,项目名称:ProgressManager,代码行数:43,代码来源:a.java

示例4: onKey

@Override
public boolean onKey(DialogInterface dialog, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
        finishActivity();
    }
    return false;
}
 
开发者ID:brevent,项目名称:Brevent,代码行数:7,代码来源:UnsupportedFragment.java

示例5: dispatchMediaKeyEvent

/**
 * Called to process media key events. Any {@link KeyEvent} can be passed but only media key
 * events will be handled.
 *
 * @param event A key event.
 * @return Whether the key event was handled.
 */
public boolean dispatchMediaKeyEvent(KeyEvent event) {
    int keyCode = event.getKeyCode();
    if (player == null || !isHandledMediaKey(keyCode)) {
        return false;
    }
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (keyCode == KeyEvent.KEYCODE_MEDIA_FAST_FORWARD) {
            fastForward();
        } else if (keyCode == KeyEvent.KEYCODE_MEDIA_REWIND) {
            rewind();
        } else if (event.getRepeatCount() == 0) {
            if (player == null) {
                return true;
            }
            switch (keyCode) {
                case KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE:
                    controlDispatcher.dispatchSetPlayWhenReady(player, !player.getPlayWhenReady());
                    break;
                case KeyEvent.KEYCODE_MEDIA_PLAY:
                    controlDispatcher.dispatchSetPlayWhenReady(player, true);
                    break;
                case KeyEvent.KEYCODE_MEDIA_PAUSE:
                    controlDispatcher.dispatchSetPlayWhenReady(player, false);
                    break;
                case KeyEvent.KEYCODE_MEDIA_NEXT:
                    next();
                    break;
                case KeyEvent.KEYCODE_MEDIA_PREVIOUS:
                    previous();
                    break;
                default:
                    break;
            }
        }
    }
    return true;
}
 
开发者ID:yangchaojiang,项目名称:yjPlay,代码行数:44,代码来源:PlaybackControlView.java

示例6: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_BACK
			&& event.getAction() == KeyEvent.ACTION_DOWN) {
		close();
		return true;
	}
	return super.onKeyDown(keyCode, event);
}
 
开发者ID:fengdongfei,项目名称:CXJPadProject,代码行数:9,代码来源:SobotChatActivity.java

示例7: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    boolean retVal = super.dispatchKeyEvent(event);
    if (retVal && mUrlHasFocus && mUrlFocusedWithoutAnimations
            && event.getAction() == KeyEvent.ACTION_DOWN && event.isPrintingKey()
            && event.hasNoModifiers()) {
        handleUrlFocusAnimation(mUrlHasFocus);
    }
    return retVal;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:10,代码来源:LocationBarLayout.java

示例8: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
  int action = event.getAction();
  int keyCode = event.getKeyCode();
  if (keyCode == KeyEvent.KEYCODE_VOLUME_DOWN) {
    if (action == KeyEvent.ACTION_DOWN) {
      ((AndroidCompatibility) Compatibility.get()).modifier = true;
    } else if (action == KeyEvent.ACTION_UP) {
      ((AndroidCompatibility) Compatibility.get()).modifier = false;
    }
  }
  return super.dispatchKeyEvent(event);
}
 
开发者ID:RedTroop,项目名称:Cubes_2,代码行数:13,代码来源:AndroidLauncher.java

示例9: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (KeyEvent.KEYCODE_BACK == keyCode && event.getAction() == KeyEvent.ACTION_DOWN) {
        if ((System.currentTimeMillis() - mKeyTime) > 2000) {
            mKeyTime = System.currentTimeMillis();
            Toast.makeText(getApplicationContext(), "确定要离开吗?", Toast.LENGTH_SHORT).show();
        } else {
            finish();
            System.exit(0);
        }
        return true;
    }
    return super.onKeyDown(keyCode, event);
}
 
开发者ID:bigjelly,项目名称:AndFast,代码行数:14,代码来源:MainActivity.java

示例10: dispatchKeyEvent

@Override
public boolean dispatchKeyEvent(KeyEvent event) {
    if (event.getKeyCode() == KeyEvent.KEYCODE_BACK) {
        if (event.getAction() == KeyEvent.ACTION_DOWN && event.getRepeatCount() == 0) {
            this.exitApp();
        }
        return true;
    }
    return super.dispatchKeyEvent(event);
}
 
开发者ID:devzwy,项目名称:NeiHanDuanZiTV,代码行数:10,代码来源:MainActivity.java

示例11: sendKeyEvent

@Override
public boolean sendKeyEvent(KeyEvent event) {
    if (keyboardListener != null) {
        if (event.getAction() == KeyEvent.ACTION_DOWN
                && event.getKeyCode() == KeyEvent.KEYCODE_DEL) { // Backspace key
            keyboardListener.onKeyboardBackspace();
        }
    }
    return super.sendKeyEvent(event);
}
 
开发者ID:tylersuehr7,项目名称:chips-input-layout,代码行数:10,代码来源:ChipEditText.java

示例12: onKey

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
	if (event.getAction() == KeyEvent.ACTION_DOWN) {
		if (event.isShiftPressed()) {//处理*#等键
			return false;
		}
		if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {//只处理数字
			if (result.size() < pswLength) {
				result.add(keyCode - 7);
				invalidate();
				FinishInput();
			}
			return true;
		}
		if (keyCode == KeyEvent.KEYCODE_DEL) {
			if (!result.isEmpty()) {//不为空时,删除最后一个数字
				saveResult = result.size();
				result.remove(result.size() - 1);
				invalidate();
			}
			return true;
		}
		if (keyCode == KeyEvent.KEYCODE_ENTER) {
			FinishInput();
			return true;
		}
	}
	return false;
}
 
开发者ID:rokudol,项目名称:PswText,代码行数:29,代码来源:PswText.java

示例13: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
	if (keyCode == KeyEvent.KEYCODE_BACK && event.getAction() == KeyEvent.ACTION_DOWN) {
		if ((System.currentTimeMillis() - exitTime) > 2000) {
			Toast.makeText(getApplicationContext(), "再按一次退出程序", Toast.LENGTH_SHORT).show();
			exitTime = System.currentTimeMillis();
		} else {
			finish();
			System.exit(0);
		}
		return true;
	}
	return super.onKeyDown(keyCode, event);
}
 
开发者ID:smartbeng,项目名称:PaoMovie,代码行数:14,代码来源:App.java

示例14: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (keyCode == KeyEvent.KEYCODE_BACK) {
            if (getBinding().webView.canGoBack()) {
                getBinding().webView.goBack();
            } else {
                finish();
            }
            return true;
        }
    }
    return super.onKeyDown(keyCode, event);
}
 
开发者ID:fodroid,项目名称:XDroid-Databinding,代码行数:14,代码来源:WebActivity.java

示例15: checkDoubleKeyEvent

static final boolean checkDoubleKeyEvent(KeyEvent event, View view) {
    if (DEBUG_ENABLED) {
        log.debug("dispatchKeyEvent " + mLastTouchTime + " " + event);
    }

    if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
        if (mLastTouchTime != DEFAULT_TOUCH_TIMESTAMP && (SystemClock.elapsedRealtime() - mLastTouchTime) < TOUCH_COOL_DOWN_TIME) {
            log.warn("too many key events " + view + " " + KeyEvent.ACTION_DOWN);
            return true;
        }
        mLastTouchTime = SystemClock.elapsedRealtime();
    }

    return false;
}
 
开发者ID:AgoraIO,项目名称:OpenVideoCall-Android,代码行数:15,代码来源:ViewUtil.java


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