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


Java Keyboard.KEYCODE_DELETE屬性代碼示例

本文整理匯總了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);
    }
}
 
開發者ID:rollforbugs,項目名稱:lokey,代碼行數:25,代碼來源:IME.java

示例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);
    }
}
 
開發者ID:PhilippC,項目名稱:keepass2android,代碼行數:26,代碼來源:KP2AKeyboard.java

示例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;
    }
}
 
開發者ID:zhaofengli,項目名稱:airboard,代碼行數:17,代碼來源:AirBoard.java

示例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;
      }
  }
 
開發者ID:zhaofengli,項目名稱:airboard,代碼行數:26,代碼來源:AirBoard.java

示例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);
    }
}
 
開發者ID:gvinciguerra,項目名稱:custode,代碼行數:19,代碼來源:PinCountdownActivity.java

示例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;
    }
}
 
開發者ID:Medeuz,項目名稱:CustomAndroidKeyboard,代碼行數:25,代碼來源:SimpleIME.java

示例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);
    }
}
 
開發者ID:YehtutHl,項目名稱:myan,代碼行數:17,代碼來源:SmartMyan.java

示例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));
	}
}
 
開發者ID:luoxianli,項目名稱:GridPassword,代碼行數:25,代碼來源:CustomBoardEditText.java

示例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;
    }
}
 
開發者ID:GitPhoenix,項目名稱:KeyboardView,代碼行數:26,代碼來源:EditView.java

示例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);
    }
}
 
開發者ID:accentype,項目名稱:accentype-android,代碼行數:17,代碼來源:LatinKeyboardView.java

示例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);
}
 
開發者ID:accentype,項目名稱:accentype-android,代碼行數:22,代碼來源:LatinKeyboardView.java

示例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);
        }
    }
}
 
開發者ID:wuzhendev,項目名稱:android-xnumberkeyboard,代碼行數:18,代碼來源:XNumberKeyboardView.java

示例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));
        }
    }
}
 
開發者ID:wuzhendev,項目名稱:android-xnumberkeyboard,代碼行數:16,代碼來源:XNumberKeyboardView.java

示例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);
    }
}
 
開發者ID:wuzhendev,項目名稱:android-xnumberkeyboard,代碼行數:23,代碼來源:XNumberKeyboardView.java

示例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));
    }
}
 
開發者ID:beilly,項目名稱:randomkeyboard,代碼行數:21,代碼來源:KeyboardHelper.java


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