本文整理汇总了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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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;
}