本文整理匯總了Java中android.inputmethodservice.Keyboard.KEYCODE_DELETE屬性的典型用法代碼示例。如果您正苦於以下問題:Java Keyboard.KEYCODE_DELETE屬性的具體用法?Java Keyboard.KEYCODE_DELETE怎麽用?Java Keyboard.KEYCODE_DELETE使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類android.inputmethodservice.Keyboard
的用法示例。
在下文中一共展示了Keyboard.KEYCODE_DELETE屬性的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: playClick
private void playClick(int keyCode) {
AudioManager am = (AudioManager)getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case 0x20:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case Keyboard.KEYCODE_DONE:
case 0x0a:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
case 0x38:
if (prefs.getBoolean("pref_eight_enable", false)) {
// Play random "eight" sound
MediaPlayer mPlayer = mediaEight[rand.nextInt(mediaEight.length)];
mPlayer.seekTo(0);
mPlayer.start();
}
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
}
}
示例2: playKeyClick
private void playKeyClick(int primaryCode) {
// if mAudioManager is null, we don't have the ringer state yet
// mAudioManager will be set by updateRingerMode
if (mAudioManager == null) {
if (mKeyboardSwitcher.getInputView() != null) {
updateRingerMode();
}
}
if (mSoundOn && !mSilentMode) {
// FIXME: Volume and enable should come from UI settings
// FIXME: These should be triggered after auto-repeat logic
int sound = AudioManager.FX_KEYPRESS_STANDARD;
switch (primaryCode) {
case Keyboard.KEYCODE_DELETE:
sound = AudioManager.FX_KEYPRESS_DELETE;
break;
case KEYCODE_ENTER:
sound = AudioManager.FX_KEYPRESS_RETURN;
break;
case KEYCODE_SPACE:
sound = AudioManager.FX_KEYPRESS_SPACEBAR;
break;
}
mAudioManager.playSoundEffect(sound, FX_VOLUME);
}
}
示例3: playclick
private void playclick(int keyCode){
AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case 32:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case 10:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
break;
}
}
示例4: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
InputConnection ic = getCurrentInputConnection() ;
playclick(primaryCode);
switch (primaryCode) {
case Keyboard.KEYCODE_DELETE:
ic.deleteSurroundingText(1, 0);
break;
case Keyboard.KEYCODE_SHIFT:
caps = !caps;
keyboard.setShifted(caps);
kv.invalidateAllKeys();
break;
case Keyboard.KEYCODE_DONE:
ic.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_ENTER));
break;
default:
char code = (char) primaryCode;
if(Character.isLetter(code) && caps) {
code = Character.toUpperCase(code);
}
ic.commitText(String.valueOf(code), 1);
break;
}
}
示例5: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
if (primaryCode == 0) // Tasto vuoto
return;
if (primaryCode != Keyboard.KEYCODE_DELETE)
pin = pin + Character.toString((char) primaryCode);
else if (pin.length() > 0)
pin = pin.substring(0, pin.length() - 1);
pinCodeView.setPinLength(pin.length());
if (pin.length() == 4) {
pinCodeView.postDelayed(new Runnable() {
@Override
public void run() {
checkPin();
}
}, 250);
}
}
示例6: playClick
/**
* Play sound on key press
*
* @param keyCode of pressed key
*/
private void playClick(int keyCode) {
AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case Constants.KeyCode.SPACE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case Keyboard.KEYCODE_DONE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Constants.KeyCode.RETURN:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
break;
}
}
示例7: playClick
private void playClick(int keyCode) {
AudioManager am = (AudioManager) getSystemService(AUDIO_SERVICE);
switch (keyCode) {
case 32:
am.playSoundEffect(AudioManager.FX_KEYPRESS_SPACEBAR);
break;
case Keyboard.KEYCODE_DONE:
case 10:
am.playSoundEffect(AudioManager.FX_KEYPRESS_RETURN);
break;
case Keyboard.KEYCODE_DELETE:
am.playSoundEffect(AudioManager.FX_KEYPRESS_DELETE);
break;
default:
am.playSoundEffect(AudioManager.FX_KEYPRESS_STANDARD);
}
}
示例8: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
Log.d("keydemo", "--------onkey-->" + primaryCode);
Editable editable = ed.getText();
int start = ed.getSelectionStart();
if (primaryCode == Keyboard.KEYCODE_CANCEL) {// 完成
hideKeyboard();
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {// 回退
if (editable != null && editable.length() > 0) {
if (onDelKeyEventListener != null) {
onDelKeyEventListener.onDeleteClick();
}
}
} else if (primaryCode == 57419) { // go left
if (start > 0) {
ed.setSelection(start - 1);
}
} else if (primaryCode == 57421) { // go right
if (start < ed.length()) {
ed.setSelection(start + 1);
}
} else {
editable.insert(start, Character.toString((char) primaryCode));
}
}
示例9: onKey
@Override
public void onKey(int primaryCode, int[] ints) {
Editable editable = getText();
int start = getSelectionStart();
switch (primaryCode) {
case Keyboard.KEYCODE_MODE_CHANGE:// 英文鍵盤與數字鍵盤切換-2
shiftKeyboard();
break;
case Keyboard.KEYCODE_DELETE:// 回退-5
if (editable != null && editable.length() > 0 && start > 0) {
editable.delete(start - 1, start);
}
break;
case Keyboard.KEYCODE_SHIFT:// 英文大小寫切換-1
shiftEnglish();
keyboardView.setKeyboard(keyboardEnglish);
break;
case Keyboard.KEYCODE_DONE:// 完成-4
break;
default:
editable.insert(start, Character.toString((char) primaryCode));
break;
}
}
示例10: onLongPress
@Override
protected boolean onLongPress(Key key) {
if (key.codes[0] == Keyboard.KEYCODE_CANCEL) {
getOnKeyboardActionListener().onKey(KEYCODE_OPTIONS, null);
return true;
} else if (key.codes[0] == KEYCODE_LANGUAGE_SWITCH) {
getOnKeyboardActionListener().onKey(KEYCODE_INPUT_METHOD_SWITCH, null);
return true;
} else if (key.codes[0] == Keyboard.KEYCODE_DELETE) {
// turn off server predictions during long pressing backspace key
mLastPredictionEnabled = ((SoftKeyboard)getOnKeyboardActionListener()).turnOffPredictionsIfNeeded();
mLongPressedDelete = true;
return false;
} else {
return super.onLongPress(key);
}
}
示例11: onTouchEvent
@Override
public boolean onTouchEvent(MotionEvent me) {
switch (me.getAction()) {
case MotionEvent.ACTION_UP:
int x = (int) me.getX();
int y = (int) me.getY();
List<Key> keys = getKeyboard().getKeys();
for (Key key : keys) {
if (key.codes[0] == Keyboard.KEYCODE_DELETE) {
if (mLongPressedDelete && x >= key.x && x <= key.x + key.width && y >= key.y && y <= key.y + key.height) {
// Restore server predictions on touch-up event
// because if backspace is long pressed, predictions are disabled.
((SoftKeyboard)getOnKeyboardActionListener()).enablePredictions(mLastPredictionEnabled);
mLongPressedDelete = false;
}
break;
}
}
break;
}
return super.onTouchEvent(me);
}
示例12: onDraw
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
// 遍曆所有的按鍵
List<Keyboard.Key> keys = getKeyboard().getKeys();
for (Keyboard.Key key : keys) {
// 如果是左下角空白的按鍵,重畫按鍵的背景
if (key.codes[0] == KEYCODE_EMPTY) {
drawKeyBackground(key, canvas, mDeleteBackgroundColor);
}
// 如果是右下角的刪除按鍵,重畫按鍵的背景,並且繪製刪除圖標
else if (key.codes[0] == Keyboard.KEYCODE_DELETE) {
drawKeyBackground(key, canvas, mDeleteBackgroundColor);
drawDeleteButton(key, canvas);
}
}
}
示例13: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
// 處理按鍵的點擊事件
// 點擊了刪除按鍵
if (primaryCode == Keyboard.KEYCODE_DELETE) {
if (mOnKeyboardListener != null)
mOnKeyboardListener.onDeleteKeyEvent();
}
// 點擊了數字按鍵
else if (primaryCode != KEYCODE_EMPTY) {
if (mOnKeyboardListener != null) {
mOnKeyboardListener.onInsertKeyEvent(Character.toString(
(char) primaryCode));
}
}
}
示例14: shuffleKeyboard
/**
* 隨機打亂數字鍵盤上鍵位的排列順序。
*/
public void shuffleKeyboard() {
Keyboard keyboard = getKeyboard();
if (keyboard != null && keyboard.getKeys() != null && keyboard.getKeys().size() > 0) {
Collections.shuffle(keyCodes); // 隨機排序數字
// 遍曆所有的按鍵
List<Keyboard.Key> keys = getKeyboard().getKeys();
int index = 0;
for (Keyboard.Key key : keys) {
// 如果按鍵是數字
if (key.codes[0] != KEYCODE_EMPTY && key.codes[0] != Keyboard.KEYCODE_DELETE) {
char code = keyCodes.get(index++);
key.codes[0] = code;
key.label = Character.toString(code);
}
}
setKeyboard(keyboard);
}
}
示例15: onKey
@Override
public void onKey(int primaryCode, int[] keyCodes) {
EditText editText = getEditTextByTag();
if (editText == null) return;
Editable editable = editText.getText();
int start = editText.getSelectionStart();
int end = editText.getSelectionEnd();
if (primaryCode == Keyboard.KEYCODE_CANCEL) {// 完成
hideKeyboard(editText);
} else if (primaryCode == Keyboard.KEYCODE_DELETE) {// 回退
start = start == end ? start - 1 : start;
if (!TextUtils.isEmpty(editable)) {
if (start >= 0 && end <= editable.length()) {
editable.delete(start, end);
}
}
} else {
editable.insert(start, Character.toString((char) primaryCode));
}
}