當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。