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


Java KeyEvent.KEYCODE_DEL屬性代碼示例

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


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

示例1: onKey

@Override
public boolean onKey(View v, int keyCode, KeyEvent event) {

    if ((((EditText) v).getText().toString() == null || ((EditText) v)
            .getText().toString().isEmpty())
            && keyCode == KeyEvent.KEYCODE_DEL
            && event.getAction() == KeyEvent.ACTION_DOWN) {

        Log.d("gaolei", "currentEditIndex-----------" + currentEditIndex);
        if (currentEditIndex == 6)
            currentEditIndex = 5;
        if (currentEditIndex > 0) {
            EditText editText = getEditTextFromIndex(currentEditIndex);
            Log.d("gaolei", "editText.getTag()-----------" + editText.getTag());

            editText.setText("");
            editText.requestFocusFromTouch();
            currentEditIndex--;
        }
    }

    return false;
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:23,代碼來源:CodeUnlockActivity.java

示例2: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    switch (keyCode) {
        case KeyEvent.KEYCODE_BACK:
            if (event.getRepeatCount() == 0 && mInputView != null) {
                if (mInputView.handleBack()) {
                    return true;
                }
            }
            break;

        case KeyEvent.KEYCODE_DEL:
            //if there is a currently composing text, modifying that instead of letting the app delete itself
            if (mComposing.length() > 0) {
                onKey(Keyboard.KEYCODE_DELETE, null);
                return true;
            }
            break;

        case KeyEvent.KEYCODE_ENTER:
            //letting the underlying text editor always handle these
            return false;
    }
    return super.onKeyDown(keyCode, event);
}
 
開發者ID:YehtutHl,項目名稱:myan,代碼行數:25,代碼來源:SmartMyan.java

示例3: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    Log.e("onKeyDown", "onKeyDown");
    switch (keyCode) {
        case KeyEvent.KEYCODE_DEL:
            mParent.adjustLayout(this, true);
            break;
        case KeyEvent.KEYCODE_ENTER:
            if (mParent.mFocusPanel != null) {
                mParent.mFocusPanel.clearMode();
            }
            clearMode();
            mParent.adjustLayout(this, false);
            return false;
    }
    return super.onKeyDown(keyCode, event);
}
 
開發者ID:hsj-xiaokang,項目名稱:OSchina_resources_android,代碼行數:17,代碼來源:ImagePanel.java

示例4: handleKeyUp

private boolean handleKeyUp(int keyCode) {
    if (keyCode == KeyEvent.KEYCODE_DEL) {
        // Backspace removes the least-significant digit, if available.
        if (mCount > 0) {
            mValue /= RADIX;
            mCount--;
        }
    } else if (isKeyCodeNumeric(keyCode)) {
        if (mCount < mMaxCount) {
            final int keyValue = numericKeyCodeToInt(keyCode);
            final int newValue = mValue * RADIX + keyValue;
            if (newValue <= mMaxValue) {
                mValue = newValue;
                mCount++;
            }
        }
    } else {
        return false;
    }

    final String formattedValue;
    if (mCount > 0) {
        // If the user types 01, we should always show the leading 0 even if
        // getShowLeadingZeroes() is false. Preserve typed leading zeroes by
        // using the number of digits entered as the format width.
        formattedValue = String.format("%0" + mCount + "d", mValue);
    } else {
        formattedValue = "";
    }

    setText(formattedValue);

    if (mListener != null) {
        final boolean isValid = mValue >= mMinValue;
        final boolean isFinished = mCount >= mMaxCount || mValue * RADIX > mMaxValue;
        mListener.onValueChanged(this, mValue, isValid, isFinished);
    }

    return true;
}
 
開發者ID:Gericop,項目名稱:DateTimePicker,代碼行數:40,代碼來源:NumericTextView.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: shouldConsume

/**
 * Returns true only if this utility class handles the key code.
 */
public static boolean shouldConsume(int keyCode) {
    return (keyCode == KeyEvent.KEYCODE_DPAD_LEFT || keyCode == KeyEvent.KEYCODE_DPAD_RIGHT ||
            keyCode == KeyEvent.KEYCODE_DPAD_UP || keyCode == KeyEvent.KEYCODE_DPAD_DOWN ||
            keyCode == KeyEvent.KEYCODE_MOVE_HOME || keyCode == KeyEvent.KEYCODE_MOVE_END ||
            keyCode == KeyEvent.KEYCODE_PAGE_UP || keyCode == KeyEvent.KEYCODE_PAGE_DOWN ||
            keyCode == KeyEvent.KEYCODE_DEL || keyCode == KeyEvent.KEYCODE_FORWARD_DEL);
}
 
開發者ID:TeamBrainStorm,項目名稱:SimpleUILauncher,代碼行數:10,代碼來源:FocusLogic.java

示例7: sendKeyEvent

@Override
public boolean sendKeyEvent(KeyEvent event) {
    if (keyboardListener != null) {
        if (event.getAction() == KeyEvent.ACTION_DOWN
                && event.getKeyCode() == KeyEvent.KEYCODE_DEL) { // Backspace key
            keyboardListener.onKeyboardBackspace();
        }
    }
    return super.sendKeyEvent(event);
}
 
開發者ID:tylersuehr7,項目名稱:chips-input-layout,代碼行數:10,代碼來源:ChipEditText.java

示例8: onKeyDown

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {

    switch (keyCode) {
        case KeyEvent.KEYCODE_R:
            mViewModel.addRectLayer();
            return true;
        case KeyEvent.KEYCODE_T:
            mViewModel.addTriangleLayer();
            return true;
        case KeyEvent.KEYCODE_O:
            mViewModel.addOvalLayer();
            return true;
    }

    if (mBinding.documentView.hasFocus()) {
        switch (keyCode) {
            case KeyEvent.KEYCODE_DEL:
            case KeyEvent.KEYCODE_FORWARD_DEL:
                return onContextMenuAction(DELETE);
        }

        if (event.isCtrlPressed()) {
            switch (keyCode) {
                case KeyEvent.KEYCODE_X:
                    return onContextMenuAction(CUT);
                case KeyEvent.KEYCODE_C:
                    return onContextMenuAction(COPY);
                case KeyEvent.KEYCODE_V:
                    return onContextMenuAction(PASTE);
                case KeyEvent.KEYCODE_D:
                    return onContextMenuAction(DUPLICATE);
                case KeyEvent.KEYCODE_G:
                    return onContextMenuAction(GROUP);
            }
        }
    }

    return super.onKeyDown(keyCode, event);
}
 
開發者ID:google,項目名稱:spline,代碼行數:40,代碼來源:EditorActivity.java

示例9: processDelKey

public boolean processDelKey(KeyEvent event)
{
    if (event.getAction() == KeyEvent.ACTION_DOWN && event.getKeyCode() == KeyEvent.KEYCODE_DEL
            && getText().length() == 0 && !toBeDeleted)
    {
        toBeDeleted = true;
        if (formulaChangeIf != null)
        {
            formulaChangeIf.onDelete(this);
            return true;
        }
    }
    return false;
}
 
開發者ID:mkulesh,項目名稱:microMathematics,代碼行數:14,代碼來源:CustomEditText.java

示例10: findItemsWithShortcutForKey

@SuppressWarnings("deprecation")
void findItemsWithShortcutForKey(List<MenuItemImpl> items, int keyCode, KeyEvent event) {
    final boolean qwerty = isQwertyMode();
    final int metaState = event.getMetaState();
    final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
    // Get the chars associated with the keyCode (i.e using any chording combo)
    final boolean isKeyCodeMapped = event.getKeyData(possibleChars);
    // The delete key is not mapped to '\b' so we treat it specially
    if (!isKeyCodeMapped && (keyCode != KeyEvent.KEYCODE_DEL)) {
        return;
    }

    // Look for an item whose shortcut is this key.
    final int N = mItems.size();
    for (int i = 0; i < N; i++) {
        MenuItemImpl item = mItems.get(i);
        if (item.hasSubMenu()) {
            ((MenuBuilder)item.getSubMenu()).findItemsWithShortcutForKey(items, keyCode, event);
        }
        final char shortcutChar = qwerty ? item.getAlphabeticShortcut() : item.getNumericShortcut();
        if (((metaState & (KeyEvent.META_SHIFT_ON | KeyEvent.META_SYM_ON)) == 0) &&
              (shortcutChar != 0) &&
              (shortcutChar == possibleChars.meta[0]
                  || shortcutChar == possibleChars.meta[2]
                  || (qwerty && shortcutChar == '\b' &&
                      keyCode == KeyEvent.KEYCODE_DEL)) &&
              item.isEnabled()) {
            items.add(item);
        }
    }
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:31,代碼來源:MenuBuilder.java

示例11: findItemWithShortcutForKey

@SuppressWarnings("deprecation")
MenuItemImpl findItemWithShortcutForKey(int keyCode, KeyEvent event) {
    // Get all items that can be associated directly or indirectly with the keyCode
    ArrayList<MenuItemImpl> items = mTempShortcutItemList;
    items.clear();
    findItemsWithShortcutForKey(items, keyCode, event);

    if (items.isEmpty()) {
        return null;
    }

    final int metaState = event.getMetaState();
    final KeyCharacterMap.KeyData possibleChars = new KeyCharacterMap.KeyData();
    // Get the chars associated with the keyCode (i.e using any chording combo)
    event.getKeyData(possibleChars);

    // If we have only one element, we can safely returns it
    final int size = items.size();
    if (size == 1) {
        return items.get(0);
    }

    final boolean qwerty = isQwertyMode();
    // If we found more than one item associated with the key,
    // we have to return the exact match
    for (int i = 0; i < size; i++) {
        final MenuItemImpl item = items.get(i);
        final char shortcutChar = qwerty ? item.getAlphabeticShortcut() :
                item.getNumericShortcut();
        if ((shortcutChar == possibleChars.meta[0] &&
                (metaState & KeyEvent.META_ALT_ON) == 0)
            || (shortcutChar == possibleChars.meta[2] &&
                (metaState & KeyEvent.META_ALT_ON) != 0)
            || (qwerty && shortcutChar == '\b' &&
                keyCode == KeyEvent.KEYCODE_DEL)) {
            return item;
        }
    }
    return null;
}
 
開發者ID:treasure-lau,項目名稱:CSipSimple,代碼行數:40,代碼來源:MenuBuilder.java

示例12: deleteSurroundingText

@Override
public boolean deleteSurroundingText(int beforeLength, int afterLength) {
    //軟鍵盤的刪除鍵 DEL 無法直接監聽,自己發送del事件
    if (beforeLength == 1 && afterLength == 0) {
        return super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_DOWN, KeyEvent.KEYCODE_DEL))
                && super.sendKeyEvent(new KeyEvent(KeyEvent.ACTION_UP, KeyEvent.KEYCODE_DEL));
    }
    return super.deleteSurroundingText(beforeLength, afterLength);
}
 
開發者ID:paradoxie,項目名稱:DizzyPassword,代碼行數:9,代碼來源:PswInputView.java

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

示例14: onKeyDown

@Override
public boolean onKeyDown(View view, Editable content, int keyCode, KeyEvent event) {
    if (keyCode == KeyEvent.KEYCODE_DEL) {
        NumberEditText.this.backspace();
    }
    return super.onKeyDown(view, content, keyCode, event);
}
 
開發者ID:tranleduy2000,項目名稱:floating_calc,代碼行數:7,代碼來源:NumberEditText.java

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


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