當前位置: 首頁>>代碼示例>>Java>>正文


Java KeyEvent.KEYCODE_9屬性代碼示例

本文整理匯總了Java中android.view.KeyEvent.KEYCODE_9屬性的典型用法代碼示例。如果您正苦於以下問題:Java KeyEvent.KEYCODE_9屬性的具體用法?Java KeyEvent.KEYCODE_9怎麽用?Java KeyEvent.KEYCODE_9使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在android.view.KeyEvent的用法示例。


在下文中一共展示了KeyEvent.KEYCODE_9屬性的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getValFromKeyCode

private static int getValFromKeyCode(int keyCode) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_0:
            return 0;
        case KeyEvent.KEYCODE_1:
            return 1;
        case KeyEvent.KEYCODE_2:
            return 2;
        case KeyEvent.KEYCODE_3:
            return 3;
        case KeyEvent.KEYCODE_4:
            return 4;
        case KeyEvent.KEYCODE_5:
            return 5;
        case KeyEvent.KEYCODE_6:
            return 6;
        case KeyEvent.KEYCODE_7:
            return 7;
        case KeyEvent.KEYCODE_8:
            return 8;
        case KeyEvent.KEYCODE_9:
            return 9;
        default:
            return -1;
    }
}
 
開發者ID:ttpho,項目名稱:TimePicker,代碼行數:26,代碼來源:TimePickerDialog.java

示例2: getValFromKeyCode

private int getValFromKeyCode(int keyCode) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_0:
            return 0;
        case KeyEvent.KEYCODE_1:
            return 1;
        case KeyEvent.KEYCODE_2:
            return 2;
        case KeyEvent.KEYCODE_3:
            return 3;
        case KeyEvent.KEYCODE_4:
            return 4;
        case KeyEvent.KEYCODE_5:
            return 5;
        case KeyEvent.KEYCODE_6:
            return 6;
        case KeyEvent.KEYCODE_7:
            return 7;
        case KeyEvent.KEYCODE_8:
            return 8;
        case KeyEvent.KEYCODE_9:
            return 9;
        default:
            return -1;
    }
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:26,代碼來源:TimePickerDialog.java

示例3: sendDtmf

/**
 * Send a dtmf signal to a call
 * 
 * @param callId the call to send the signal
 * @param keyCode the keyCode to send (android style)
 * @return
 */
public int sendDtmf(int callId, int keyCode) throws SameThreadException {
    if (!created) {
        return -1;
    }
    String keyPressed = "";
    // Since some device (xoom...) are apparently buggy with key character
    // map loading...
    // we have to do crappy thing here
    if (keyCode >= KeyEvent.KEYCODE_0 && keyCode <= KeyEvent.KEYCODE_9) {
        keyPressed = Integer.toString(keyCode - KeyEvent.KEYCODE_0);
    } else if (keyCode == KeyEvent.KEYCODE_POUND) {
        keyPressed = "#";
    } else if (keyCode == KeyEvent.KEYCODE_STAR) {
        keyPressed = "*";
    } else {
        // Fallback... should never be there if using visible dialpad, but
        // possible using keyboard
        KeyCharacterMap km = KeyCharacterMap.load(KeyCharacterMap.NUMERIC);
        keyPressed = Integer.toString(km.getNumber(keyCode));
    }
    return sendDtmf(callId, keyPressed);
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:29,代碼來源:PjSipService.java

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

示例5: sendFunctionKey

/**
 * @param key
 * @return successful
 */
private boolean sendFunctionKey(int keyCode) {
	switch (keyCode) {
	case KeyEvent.KEYCODE_1:
		((vt320) buffer).keyPressed(vt320.KEY_F1, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_2:
		((vt320) buffer).keyPressed(vt320.KEY_F2, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_3:
		((vt320) buffer).keyPressed(vt320.KEY_F3, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_4:
		((vt320) buffer).keyPressed(vt320.KEY_F4, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_5:
		((vt320) buffer).keyPressed(vt320.KEY_F5, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_6:
		((vt320) buffer).keyPressed(vt320.KEY_F6, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_7:
		((vt320) buffer).keyPressed(vt320.KEY_F7, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_8:
		((vt320) buffer).keyPressed(vt320.KEY_F8, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_9:
		((vt320) buffer).keyPressed(vt320.KEY_F9, ' ', 0);
		return true;
	case KeyEvent.KEYCODE_0:
		((vt320) buffer).keyPressed(vt320.KEY_F10, ' ', 0);
		return true;
	default:
		return false;
	}
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:40,代碼來源:TerminalKeyListener.java

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

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

示例8: sendKeyEvent

@Override
public boolean sendKeyEvent(KeyEvent event) {
    if (event.getAction() == KeyEvent.ACTION_DOWN) {
        if (event.getKeyCode() >= KeyEvent.KEYCODE_0
                && event.getKeyCode() <= KeyEvent.KEYCODE_9) {
            char c = event.getKeyCharacterMap().getNumber(event.getKeyCode());
            commitText(String.valueOf(c), 1);
        } else if (event.getKeyCode() == KeyEvent.KEYCODE_DEL) {
            deleteSurroundingText(1, 0);
        }
    }
    return super.sendKeyEvent(event);
}
 
開發者ID:Onum,項目名稱:EditCodeView,代碼行數:13,代碼來源:EditCodeInputConnection.java

示例9: isKeyCodeNumeric

private static boolean isKeyCodeNumeric(int keyCode) {
    return keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1
            || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3
            || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5
            || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7
            || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9;
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:7,代碼來源:NumericTextView.java

示例10: processKeyUp

/**
 * For keyboard mode, processes key events.
 *
 * @param keyCode the pressed key.
 * @return true if the key was successfully processed, false otherwise.
 */
private boolean processKeyUp(int keyCode) {
    if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) {
        dismiss();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_TAB) {
        if (mInKbMode) {
            if (isTypedTimeFullyLegal()) {
                finishKbMode(true);
            }
            return true;
        }
    } else if (keyCode == KeyEvent.KEYCODE_ENTER) {
        if (mInKbMode) {
            if (!isTypedTimeFullyLegal()) {
                return true;
            }
            finishKbMode(false);
        }
        sendBroadcastResult();
        handleCallbackResult(mTimePicker);
        dismiss();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DEL) {
        if (mInKbMode) {
            if (!mTypedTimes.isEmpty()) {
                int deleted = deleteLastTypedKey();
                String deletedKeyStr;
                if (deleted == getAmOrPmKeyCode(AM)) {
                    deletedKeyStr = mAmText;
                } else if (deleted == getAmOrPmKeyCode(PM)) {
                    deletedKeyStr = mPmText;
                } else {
                    deletedKeyStr = String.format(Locale.ENGLISH, "%d", getValFromKeyCode(deleted));
                }
                Utils.tryAccessibilityAnnounce(mTimePicker,
                        String.format(mDeletedKeyFormat, deletedKeyStr));
                updateDisplay(true);
            }
        }
    } else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1
            || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3
            || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5
            || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7
            || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9
            || (!mIs24HourMode &&
            (keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) {
        if (!mInKbMode) {
            if (mTimePicker == null) {
                // Something's wrong, because time picker should definitely not be null.
                Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null.");
                return true;
            }
            mTypedTimes.clear();
            tryStartingKbMode(keyCode);
            return true;
        }
        // We're already in keyboard mode.
        if (addKeyIfLegal(keyCode)) {
            updateDisplay(false);
        }
        return true;
    }
    return false;
}
 
開發者ID:ttpho,項目名稱:TimePicker,代碼行數:70,代碼來源:TimePickerDialog.java

示例11: processKeyUp

/**
 * For keyboard mode, processes key events.
 *
 * @param keyCode the pressed key.
 * @return true if the key was successfully processed, false otherwise.
 */
private boolean processKeyUp(int keyCode) {
    if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) {
        dismiss();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_TAB) {
        if (mInKbMode) {
            if (isTypedTimeFullyLegal()) {
                finishKbMode(true);
            }
            return true;
        }
    } else if (keyCode == KeyEvent.KEYCODE_ENTER) {
        if (mInKbMode) {
            if (!isTypedTimeFullyLegal()) {
                return true;
            }
            finishKbMode(false);
        }
        if (mCallback != null) {
            mCallback.onTimeSet(mTimePicker,
                    mTimePicker.getHours(), mTimePicker.getMinutes());
        }
        dismiss();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DEL) {
        if (mInKbMode) {
            if (!mTypedTimes.isEmpty()) {
                int deleted = deleteLastTypedKey();
                String deletedKeyStr;
                if (deleted == getAmOrPmKeyCode(AM)) {
                    deletedKeyStr = mAmText;
                } else if (deleted == getAmOrPmKeyCode(PM)) {
                    deletedKeyStr = mPmText;
                } else {
                    deletedKeyStr = String.format("%d", getValFromKeyCode(deleted));
                }
                Utils.tryAccessibilityAnnounce(mTimePicker,
                        String.format(mDeletedKeyFormat, deletedKeyStr));
                updateDisplay(true);
            }
        }
    } else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1
            || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3
            || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5
            || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7
            || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9
            || (!mIs24HourMode &&
            (keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) {
        if (!mInKbMode) {
            if (mTimePicker == null) {
                // Something's wrong, because time picker should definitely not be null.
                Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null.");
                return true;
            }
            mTypedTimes.clear();
            tryStartingKbMode(keyCode);
            return true;
        }
        // We're already in keyboard mode.
        if (addKeyIfLegal(keyCode)) {
            updateDisplay(false);
        }
        return true;
    }
    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:72,代碼來源:TimePickerDialog.java

示例12: processKeyUp

/**
 * For keyboard mode, processes key events.
 * @param keyCode the pressed key.
 * @return true if the key was successfully processed, false otherwise.
 */
private boolean processKeyUp(int keyCode) {
    if (keyCode == KeyEvent.KEYCODE_ESCAPE || keyCode == KeyEvent.KEYCODE_BACK) {
        if(isCancelable()) dismiss();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_TAB) {
        if(mInKbMode) {
            if (isTypedTimeFullyLegal()) {
                finishKbMode(true);
            }
            return true;
        }
    } else if (keyCode == KeyEvent.KEYCODE_ENTER) {
        if (mInKbMode) {
            if (!isTypedTimeFullyLegal()) {
                return true;
            }
            finishKbMode(false);
        }
        if (mCallback != null) {
            mCallback.onTimeSet(this,
                    mTimePicker.getHours(), mTimePicker.getMinutes(), mTimePicker.getSeconds());
        }
        dismiss();
        return true;
    } else if (keyCode == KeyEvent.KEYCODE_DEL) {
        if (mInKbMode) {
            if (!mTypedTimes.isEmpty()) {
                int deleted = deleteLastTypedKey();
                String deletedKeyStr;
                if (deleted == getAmOrPmKeyCode(AM)) {
                    deletedKeyStr = mAmText;
                } else if (deleted == getAmOrPmKeyCode(PM)) {
                    deletedKeyStr = mPmText;
                } else {
                    deletedKeyStr = String.format("%d", getValFromKeyCode(deleted));
                }
                Utils.tryAccessibilityAnnounce(mTimePicker,
                        String.format(mDeletedKeyFormat, deletedKeyStr));
                updateDisplay(true);
            }
        }
    } else if (keyCode == KeyEvent.KEYCODE_0 || keyCode == KeyEvent.KEYCODE_1
            || keyCode == KeyEvent.KEYCODE_2 || keyCode == KeyEvent.KEYCODE_3
            || keyCode == KeyEvent.KEYCODE_4 || keyCode == KeyEvent.KEYCODE_5
            || keyCode == KeyEvent.KEYCODE_6 || keyCode == KeyEvent.KEYCODE_7
            || keyCode == KeyEvent.KEYCODE_8 || keyCode == KeyEvent.KEYCODE_9
            || (!mIs24HourMode &&
                    (keyCode == getAmOrPmKeyCode(AM) || keyCode == getAmOrPmKeyCode(PM)))) {
        if (!mInKbMode) {
            if (mTimePicker == null) {
                // Something's wrong, because time picker should definitely not be null.
                Log.e(TAG, "Unable to initiate keyboard mode, TimePicker was null.");
                return true;
            }
            mTypedTimes.clear();
            tryStartingKbMode(keyCode);
            return true;
        }
        // We're already in keyboard mode.
        if (addKeyIfLegal(keyCode)) {
            updateDisplay(false);
        }
        return true;
    }
    return false;
}
 
開發者ID:LingjuAI,項目名稱:AssistantBySDK,代碼行數:71,代碼來源:TimePickerDialog.java


注:本文中的android.view.KeyEvent.KEYCODE_9屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。