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


Java KeyEvent.KEYCODE_ENTER属性代码示例

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


在下文中一共展示了KeyEvent.KEYCODE_ENTER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
	switch (keyCode) {
	case KeyEvent.KEYCODE_DPAD_CENTER:
	case KeyEvent.KEYCODE_ENTER:
		if (!isEnabled()) {
			return true;
		}
		if (isClickable() && isPressed() && mSelectedPosition >= 0
				&& mAdapter != null
				&& mSelectedPosition < mAdapter.getCount()) {

			final View view = getChildAt(mSelectedPosition - mFirstPosition);
			if (view != null) {
				performItemClick(view, mSelectedPosition, mSelectedColId);
				view.setPressed(false);
			}
			setPressed(false);
			return true;
		}
		break;
	}
	return super.onKeyUp(keyCode, event);
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:24,代码来源:AbsHListView.java

示例2: dispatchKeyEvent

/**
 * 操作软键盘
 */
@Override public boolean dispatchKeyEvent(KeyEvent event) {
  if (event.getKeyCode() == KeyEvent.KEYCODE_ENTER) {
    InputMethodManager inputMethodManager =
        (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
    if (inputMethodManager.isActive()) {
      //EventBus.getDefault().post(new EventUtil(keyword));
      inputMethodManager.hideSoftInputFromWindow(
          ProductDetailActivity.this.getCurrentFocus().getWindowToken(), 0);
    }
    //通知接受
    return true;
  }

  return super.dispatchKeyEvent(event);
}
 
开发者ID:lwd1815,项目名称:Selector,代码行数:18,代码来源:ProductDetailActivity.java

示例3: onEditorAction

@Override
public boolean onEditorAction(TextView arg0, int actionId, KeyEvent arg2) {
	// hide the keyboard and search the web when the enter key
	// button is pressed
	if (actionId == EditorInfo.IME_ACTION_GO || actionId == EditorInfo.IME_ACTION_DONE
			|| actionId == EditorInfo.IME_ACTION_NEXT
			|| actionId == EditorInfo.IME_ACTION_SEND
			|| actionId == EditorInfo.IME_ACTION_SEARCH
			|| (arg2.getAction() == KeyEvent.KEYCODE_ENTER)) {
		InputMethodManager imm = (InputMethodManager) getSystemService(Context.INPUT_METHOD_SERVICE);
		imm.hideSoftInputFromWindow(mSearch.getWindowToken(), 0);
		searchTheWeb(mSearch.getText().toString());
		LightningView v=getCurrentWebView();
		if (v != null) {
			v.requestFocus();
		}
		return true;
	}
	return false;
}
 
开发者ID:NewCasino,项目名称:browser,代码行数:20,代码来源:BrowserActivity.java

示例4: onKey

@Override
public boolean onKey(View view, int keyCode, KeyEvent keyEvent) {
    int id = view.getId();
    if (id == R.id.kf5_search_content_edittext) {
        if (keyCode == KeyEvent.KEYCODE_ENTER) {
            if (!TextUtils.isEmpty(mEditText.getText()) && !TextUtils.isEmpty(mEditText.getText().toString().trim())) {
                Utils.hideSoftInput(mActivity, mEditText);
                mReminderLayout.setVisibility(View.VISIBLE);
                mSearchLayout.setVisibility(View.GONE);
                mListView.setRefresh(false);
                isSearch = true;
                showDialog = true;
                nextPage = 1;
                presenter.searchDocument(HelpCenterRequestType.SEARCH);
            } else {
                showToast(getString(R.string.kf5_content_not_null));
            }
        }
    }
    return false;
}
 
开发者ID:Zyj163,项目名称:yyox,代码行数:21,代码来源:HelpCenterActivity.java

示例5: onKey

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (event.isShiftPressed()) {// Handle * # and other keys
            return false;
        }
        if (keyCode >= KeyEvent.KEYCODE_0
                && keyCode <= KeyEvent.KEYCODE_9) {// Only deal with
                                                   // numbers
            if (result.size() < pswLength) {
                result.add(keyCode - 7);
                invalidate();
                ensureFinishInput();
            }
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_DEL) {
            if (!result.isEmpty()) {// Not empty, delete the last one
                saveResult = result.size();
                result.remove(result.size() - 1);
                invalidate();
            }
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_ENTER) {
            ensureFinishInput();
            return true;
        }
    }
    return false;
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:31,代码来源:SafePswText.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:
            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:pooyafaroka,项目名称:PlusGram,代码行数:33,代码来源:NumberPicker.java

示例7: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if ((keyCode == KeyEvent.KEYCODE_DPAD_CENTER)
            || (keyCode == KeyEvent.KEYCODE_ENTER)) {
        cancelLongpress();
    }
    return super.onKeyUp(keyCode, event);
}
 
开发者ID:dftec-es,项目名称:planetcon,代码行数:8,代码来源:NumberPicker.java

示例8: 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() < count) {
                result.add(keyCode - 7);
                invalidate();
                ensureFinishInput();
            }
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_DEL) {
            if (!result.isEmpty()) {//不为空,删除最后一个
                result.remove(result.size() - 1);
                invalidate();
            }
            return true;
        }
        if (keyCode == KeyEvent.KEYCODE_ENTER) {
            ensureFinishInput();
            return true;
        }
    }
    return false;
}
 
开发者ID:paradoxie,项目名称:DizzyPassword,代码行数:28,代码来源:PswInputView.java

示例9: 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

示例10: checkDoubleKeyEvent

static final boolean checkDoubleKeyEvent(KeyEvent event, View view) {
    if (DEBUG_ENABLED && false) {
        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,项目名称:OpenLive-Android,代码行数:15,代码来源:ViewUtil.java

示例11: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_ENTER) {
        if (mProcessing) {
            updateStatus("Still processing, please wait");
            return true;
        }
        updateStatus("Running photo recognition");
        mProcessing = true;
        loadPhoto();
        return true;
    }
    return super.onKeyUp(keyCode, event);
}
 
开发者ID:googlecodelabs,项目名称:androidthings-imageclassifier,代码行数:14,代码来源:ImageClassifierActivity.java

示例12: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    // We need to handle focus change within the SimpleMonthView because we are simulating
    // multiple Views. The arrow keys will move between days until there is no space (no
    // day to the left, top, right, or bottom). Focus forward and back jumps out of the
    // SimpleMonthView, skipping over other SimpleMonthViews in the parent ViewPager
    // to the next focusable View in the hierarchy.
    boolean focusChanged = false;
    switch (event.getKeyCode()) {
        case KeyEvent.KEYCODE_DPAD_LEFT:
            if (event.hasNoModifiers()) {
                focusChanged = moveOneDay(isLayoutRtl());
            }
            break;
        case KeyEvent.KEYCODE_DPAD_RIGHT:
            if (event.hasNoModifiers()) {
                focusChanged = moveOneDay(!isLayoutRtl());
            }
            break;
        case KeyEvent.KEYCODE_DPAD_UP:
            if (event.hasNoModifiers()) {
                ensureFocusedDay();
                if (mHighlightedDay > 7) {
                    mHighlightedDay -= 7;
                    focusChanged = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_DPAD_DOWN:
            if (event.hasNoModifiers()) {
                ensureFocusedDay();
                if (mHighlightedDay <= mDaysInMonth - 7) {
                    mHighlightedDay += 7;
                    focusChanged = true;
                }
            }
            break;
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            if (mHighlightedDay != -1) {
                onDayClicked(mHighlightedDay);
                return true;
            }
            break;
        case KeyEvent.KEYCODE_TAB: {
            int focusChangeDirection = 0;
            if (event.hasNoModifiers()) {
                focusChangeDirection = View.FOCUS_FORWARD;
            } else if (event.hasModifiers(KeyEvent.META_SHIFT_ON)) {
                focusChangeDirection = View.FOCUS_BACKWARD;
            }
            if (focusChangeDirection != 0) {
                final ViewParent parent = getParent();
                // move out of the ViewPager next/previous
                View nextFocus = this;
                do {
                    nextFocus = nextFocus.focusSearch(focusChangeDirection);
                } while (nextFocus != null && nextFocus != this &&
                        nextFocus.getParent() == parent);
                if (nextFocus != null) {
                    nextFocus.requestFocus();
                    return true;
                }
            }
            break;
        }
    }
    if (focusChanged) {
        invalidate();
        return true;
    } else {
        return super.onKeyDown(keyCode, event);
    }
}
 
开发者ID:Gericop,项目名称:DateTimePicker,代码行数:74,代码来源:SimpleMonthView.java

示例13: onKeyUp

@Override
public boolean onKeyUp(int keyCode, KeyEvent event) {
    if (event.isTracking()) {
        if (!mChildrenFocused && keyCode == KeyEvent.KEYCODE_ENTER) {
            mChildrenFocused = true;
            ArrayList<View> focusableChildren = getFocusables(FOCUS_FORWARD);
            focusableChildren.remove(this);
            int childrenCount = focusableChildren.size();
            switch (childrenCount) {
                case 0:
                    mChildrenFocused = false;
                    break;
                case 1: {
                    if (getTag() instanceof ItemInfo) {
                        ItemInfo item = (ItemInfo) getTag();
                        if (item.spanX == 1 && item.spanY == 1) {
                            focusableChildren.get(0).performClick();
                            mChildrenFocused = false;
                            return true;
                        }
                    }
                    // continue;
                }
                default:
                    focusableChildren.get(0).requestFocus();
                    return true;
            }
        }
    }
    return super.onKeyUp(keyCode, event);
}
 
开发者ID:TeamBrainStorm,项目名称:SimpleUILauncher,代码行数:31,代码来源:LauncherAppWidgetHostView.java

示例14: onKeyUp

@Override
public boolean onKeyUp(final int keyCode, final KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_DPAD_CENTER:
        case KeyEvent.KEYCODE_ENTER:
            /* Remove the repeater, but call the hook one more time */
            removeCallbacks(mRepeater);
            if (mStartTime != 0) {
                doRepeat(true);
                mStartTime = 0;
            }
    }
    return super.onKeyUp(keyCode, event);
}
 
开发者ID:PhoenixDevTeam,项目名称:Phoenix-for-VK,代码行数:14,代码来源:RepeatingImageButton.java

示例15: handleKeyActionDown

private boolean handleKeyActionDown(View v, int keyCode, KeyEvent event) {
    if(isInterruptOnKeyActionDown(v, keyCode, event)){
        return true;
    }
    switch (keyCode){
        case KeyEvent.KEYCODE_DPAD_UP:
            PLog.d(TAG,"onKeyActionDown : dpad up");
            return onKeyActionDownDpadUp(v, keyCode, event);

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

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

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

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

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

        case KeyEvent.KEYCODE_MENU:
            PLog.d(TAG,"onKeyActionDown : dpad menu");
            return onKeyActionDownDpadMenu(v, keyCode, event);
    }
    return false;
}
 
开发者ID:jiajunhui,项目名称:PlayerBase,代码行数:36,代码来源:BaseFocusCover.java


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