本文整理汇总了Java中android.view.KeyEvent.KEYCODE_MENU属性的典型用法代码示例。如果您正苦于以下问题:Java KeyEvent.KEYCODE_MENU属性的具体用法?Java KeyEvent.KEYCODE_MENU怎么用?Java KeyEvent.KEYCODE_MENU使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.view.KeyEvent
的用法示例。
在下文中一共展示了KeyEvent.KEYCODE_MENU属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
final int uniChar = event.getUnicodeChar();
final boolean handled = super.onKeyDown(keyCode, event);
final boolean isKeyNotWhitespace = uniChar > 0 && !Character.isWhitespace(uniChar);
if (!handled && acceptFilter() && isKeyNotWhitespace) {
boolean gotKey = TextKeyListener.getInstance().onKeyDown(mWorkspace, mDefaultKeySsb,
keyCode, event);
if (gotKey && mDefaultKeySsb != null && mDefaultKeySsb.length() > 0) {
// something usable has been typed - start a search
// the typed text will be retrieved and cleared by
// showSearchDialog()
// If there are multiple keystrokes before the search dialog takes focus,
// onSearchRequested() will be called for every keystroke,
// but it is idempotent, so it's fine.
return onSearchRequested();
}
}
// Eat the long press event so the keyboard doesn't come up.
if (keyCode == KeyEvent.KEYCODE_MENU && event.isLongPress()) {
return true;
}
return handled;
}
示例2: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (isOnKeyLongPress) {
isOnKeyLongPress = false;
return true;
}
switch (keyCode) {
case KeyEvent.KEYCODE_BACK:
if (onBottomDragListener != null) {
onBottomDragListener.onDragBottom(false);
return true;
}
break;
case KeyEvent.KEYCODE_MENU:
if (onBottomDragListener != null) {
onBottomDragListener.onDragBottom(true);
return true;
}
break;
default:
break;
}
return super.onKeyUp(keyCode, event);
}
示例3: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
// Ignore the menu key if we are currently dragging or are on the custom content screen
if (!isOnCustomContent() && !mDragController.isDragging()) {
// Close any open folders
closeFolder();
// Close any shortcuts containers
closeShortcutsContainer();
// Stop resizing any widgets
mWorkspace.exitWidgetResizeMode();
// Show the overview mode if we are on the workspace
if (mState == State.WORKSPACE && !mWorkspace.isInOverviewMode() &&
!mWorkspace.isSwitchingState()) {
mOverviewPanel.requestFocus();
showOverviewMode(true, true /* requestButtonFocus */);
}
}
return true;
}
return super.onKeyUp(keyCode, event);
}
示例4: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
// Ignore the menu key if we are currently dragging or are on the custom content screen
if (!isOnCustomContent() && !mDragController.isDragging()) {
// Close any open floating view
AbstractFloatingView.closeAllOpenViews(this);
// Stop resizing any widgets
mWorkspace.exitWidgetResizeMode();
// Show the overview mode if we are on the workspace
if (mState == State.WORKSPACE && !mWorkspace.isInOverviewMode() &&
!mWorkspace.isSwitchingState()) {
mOverviewPanel.requestFocus();
showOverviewMode(true, true /* requestButtonFocus */);
}
}
return true;
}
return super.onKeyUp(keyCode, event);
}
示例5: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
boolean isKeyCodeSupported = keyCode != KeyEvent.KEYCODE_BACK &&
keyCode != KeyEvent.KEYCODE_VOLUME_UP &&
keyCode != KeyEvent.KEYCODE_VOLUME_DOWN &&
keyCode != KeyEvent.KEYCODE_VOLUME_MUTE &&
keyCode != KeyEvent.KEYCODE_MENU &&
keyCode != KeyEvent.KEYCODE_CALL &&
keyCode != KeyEvent.KEYCODE_ENDCALL;
if (isInPlaybackState() && isKeyCodeSupported && mController != null) {
if (keyCode == KeyEvent.KEYCODE_HEADSETHOOK ||
keyCode == KeyEvent.KEYCODE_MEDIA_PLAY_PAUSE) {
if (isPlaying()) {
pause();
// mController.setVisibility(VISIBLE);
} else {
start();
// mController.setVisibility(GONE);
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_PLAY) {
if (!isPlaying()) {
start();
// mController.setVisibility(GONE);
}
return true;
} else if (keyCode == KeyEvent.KEYCODE_MEDIA_STOP
|| keyCode == KeyEvent.KEYCODE_MEDIA_PAUSE) {
if (isPlaying()) {
pause();
// mController.setVisibility(VISIBLE);
}
return true;
} else {
// toggleMediaControlsVisiblity();
}
}
return super.onKeyDown(keyCode, event);
}
示例6: onKeyDown
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
toggleDrawer();
return true;
}
return super.onKeyDown(keyCode, event);
}
示例7: onKeyDown
/**
* 拦截Menu/KeyBack事件
*/
@Override
public boolean onKeyDown(int key_code, KeyEvent event)
{
if (key_code == KeyEvent.KEYCODE_BACK)
{
if (currentPath.equalsIgnoreCase(sdcard_root_path))
{
return super.onKeyDown(key_code, event);
}
else if (!currentPath.equals(""))
{
// showDirectoryContents(getParent(currentPath));
onReturnPrevLayer(currentPath);
}
return true;
}
else if ((key_code == KeyEvent.KEYCODE_MENU) && (allowMenuKey))
{
Intent intent = new Intent(this, FileExplorerSettingsActivity.class);
startActivityForResult(intent, RC_SET_FILE_ROOT);
return true;
}
else
{
return super.onKeyDown(key_code, event);
}
}
示例8: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
actionBarLayout.onKeyUp(keyCode, event);
}
return super.onKeyUp(keyCode, event);
}
示例9: onKeyDown
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_ENTER) {
if (mSearch.hasFocus()) {
searchTheWeb(mSearch.getText().toString());
}
} else if ((keyCode == KeyEvent.KEYCODE_MENU) && (Build.VERSION.SDK_INT <= 16)
&& (Build.MANUFACTURER.compareTo("LGE") == 0)) {
// Workaround for stupid LG devices that crash
return true;
}
return super.onKeyDown(keyCode, event);
}
示例10: isSystemKey
@TargetApi(Build.VERSION_CODES.JELLY_BEAN)
public boolean isSystemKey(KeyEvent event, int keyCode) {
GenericGamepad gamepad = event==null ? null : resolveGamepad(event.getDevice().getDescriptor(), event.getDeviceId());
if (gamepad!=null && gamepad.getOriginCode(keyCode)!=0) return false;
return
keyCode == KeyEvent.KEYCODE_BACK ||
keyCode == KeyEvent.KEYCODE_MENU ||
keyCode == KeyEvent.KEYCODE_VOLUME_DOWN ||
keyCode == KeyEvent.KEYCODE_VOLUME_UP ||
keyCode == KeyEvent.KEYCODE_VOLUME_MUTE;
}
示例11: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU && mReactInstanceManager != null) {
mReactInstanceManager.showDevOptionsDialog();
return true;
}
return super.onKeyUp(keyCode, event);
}
示例12: onKeyUp
@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_MENU) {
mDevSupportManager.showDevOptionsDialog();
return true;
}
if (mDoubleTapReloadRecognizer.didDoubleTapR(keyCode, getCurrentFocus())) {
mDevSupportManager.handleReloadJS();
}
return super.onKeyUp(keyCode, event);
}
示例13: dispatchKeyEvent
@Override
public boolean dispatchKeyEvent(@NonNull KeyEvent event) {
if (event.getKeyCode() == KeyEvent.KEYCODE_MENU && event.getAction() == KeyEvent.ACTION_UP) {
showOverflowMenu();
return true;
}
return super.dispatchKeyEvent(event);
}
示例14: 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);
}
示例15: onKey
@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
if(event.getKeyCode() == KeyEvent.KEYCODE_MENU && event.getAction() != KeyEvent.ACTION_DOWN) {
return false;
}
dismiss();
return true;
}