当前位置: 首页>>代码示例>>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;未经允许,请勿转载。