类android.text.method.KeyListener源码实例Demo

下面列出了怎么用android.text.method.KeyListener的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: sana.mobile   文件: TextEntryElement.java
/**
 * gets the key listener by type
 */
protected static KeyListener getKeyListenerForType(NumericType type) {
    switch (type) {
        case DIALPAD:
            return new DialerKeyListener();
        case INTEGER:
            return new DigitsKeyListener();
        case SIGNED:
            return new DigitsKeyListener(true, false);
        case DECIMAL:
            return new DigitsKeyListener(true, true);
        case NONE:
        default:
            return null;
    }
}
 
源代码2 项目: sana.mobile   文件: TextEntryElement.java
/**
 * {@inheritDoc}
 */
@Override
protected View createView(Context c) {
    et = new EditText(c);
    et.setBackgroundResource(R.drawable.oval);
    et.setTextColor(c.getResources()
            .getColorStateList(R.color.primary_text_holo_light));
    et.setText(answer);
    et.setLayoutParams(new LayoutParams(LayoutParams.FILL_PARENT,
            LayoutParams.WRAP_CONTENT));
    if (!NumericType.NONE.equals(numericType)) {
        KeyListener listener = getKeyListenerForType(numericType);
        if (listener != null)
            et.setKeyListener(listener);
    } else {
        et.setRawInputType(InputType.TYPE_TEXT_FLAG_CAP_SENTENCES |
                TYPE_TEXT_FLAG_NO_SUGGESTIONS);
    }
    return encapsulateQuestion(c, et);
}
 
源代码3 项目: android_9.0.0_r45   文件: DialerFilter.java
private void swapPrimaryAndHint(boolean makeLettersPrimary) {
    Editable lettersText = mLetters.getText();
    Editable digitsText = mDigits.getText();
    KeyListener lettersInput = mLetters.getKeyListener();
    KeyListener digitsInput = mDigits.getKeyListener();

    if (makeLettersPrimary) {
        mLetters = mPrimary;
        mDigits = mHint;
    } else {
        mLetters = mHint;
        mDigits = mPrimary;
    }

    mLetters.setKeyListener(lettersInput);
    mLetters.setText(lettersText);
    lettersText = mLetters.getText();
    Selection.setSelection(lettersText, lettersText.length());

    mDigits.setKeyListener(digitsInput);
    mDigits.setText(digitsText);
    digitsText = mDigits.getText();
    Selection.setSelection(digitsText, digitsText.length());

    // Reset the filters
    mPrimary.setFilters(mInputFilters);
    mHint.setFilters(mInputFilters);
}
 
public boolean clearMetaKeyStates(int states) {
    final Editable content = getEditable();
    if (content == null) return false;
    KeyListener kl = mTextView.getKeyListener();
    if (kl != null) {
        try {
            kl.clearMetaKeyState(mTextView, content, states);
        } catch (AbstractMethodError e) {
            // This is an old listener that doesn't implement the
            // new method.
        }
    }
    return true;
}
 
源代码5 项目: JotaTextEditor   文件: EditableInputConnection.java
public boolean clearMetaKeyStates(int states) {
    final Editable content = getEditable();
    if (content == null) return false;
    KeyListener kl = mTextView.getKeyListener();
    if (kl != null) {
        try {
            kl.clearMetaKeyState(mTextView, content, states);
        } catch (AbstractMethodError e) {
            // This is an old listener that doesn't implement the
            // new method.
        }
    }
    return true;
}
 
源代码6 项目: BluetoothHidEmu   文件: GenericUiControls.java
/**
 * onKeyDown()
 */
@Override
public boolean processKeyDown(int keyCode, KeyEvent event) {
    
    if (mEchoEditText != null && (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        KeyListener keyListener = mEchoEditText.getKeyListener();
        keyListener.onKeyDown(mEchoEditText, mEchoEditText.getEditableText(), keyCode, event);
        return true;
    }
    return false;
}
 
源代码7 项目: BluetoothHidEmu   文件: GenericUiControls.java
/**
 * onKeyUp()
 */
@Override
public boolean processKeyUp(int keyCode, KeyEvent event) {

    if (mEchoEditText != null && (keyCode == KeyEvent.KEYCODE_VOLUME_UP || keyCode == KeyEvent.KEYCODE_VOLUME_DOWN)) {
        KeyListener keyListener = mEchoEditText.getKeyListener();
        keyListener.onKeyUp(mEchoEditText, mEchoEditText.getEditableText(), keyCode, event);
        return true;
    }

    return false;
}
 
源代码8 项目: timecat   文件: TEditText.java
@Override
public void setKeyListener(KeyListener input) {
    super.setKeyListener(input);
}
 
源代码9 项目: anvil   文件: DSL.java
public static Void keyListener(KeyListener arg) {
  return BaseDSL.attr("keyListener", arg);
}
 
源代码10 项目: anvil   文件: DSL.java
public static Void keyListener(KeyListener arg) {
  return BaseDSL.attr("keyListener", arg);
}
 
/**
 * Delegate method for the input widget
 */
public void setInputWidgetKeyListener(KeyListener input) {
    getInputWidget().setKeyListener(input);
}
 
/**
 * Delegate method for the input widget
 */
public void setInputWidgetKeyListener(KeyListener input) {
    getInputWidget().setKeyListener(input);
}
 
源代码13 项目: DevUtils   文件: EditTextUtils.java
/**
 * 设置 KeyListener
 * @param editText    {@link EditText}
 * @param keyListener {@link KeyListener}
 * @param <T>         泛型
 * @return {@link EditText}
 */
public static <T extends EditText> T setKeyListener(final T editText, final KeyListener keyListener) {
    if (editText != null) {
        editText.setKeyListener(keyListener);
    }
    return editText;
}
 
源代码14 项目: DevUtils   文件: DevHelper.java
/**
 * 设置 KeyListener
 * @param editText    {@link EditText}
 * @param keyListener {@link KeyListener}
 * @return {@link DevHelper}
 */
public DevHelper setKeyListener(final EditText editText, final KeyListener keyListener) {
    EditTextUtils.setKeyListener(editText, keyListener);
    return this;
}
 
源代码15 项目: DevUtils   文件: ViewHelper.java
/**
 * 设置 KeyListener
 * @param editText    {@link EditText}
 * @param keyListener {@link KeyListener}
 * @return {@link ViewHelper}
 */
public ViewHelper setKeyListener(final EditText editText, final KeyListener keyListener) {
    EditTextUtils.setKeyListener(editText, keyListener);
    return this;
}
 
源代码16 项目: MDPreference   文件: EditText.java
/**
    * @return the current key listener for this TextView.
    * This will frequently be null for non-EditText TextViews.
    *
    * @attr ref android.R.styleable#TextView_numeric
    * @attr ref android.R.styleable#TextView_digits
    * @attr ref android.R.styleable#TextView_phoneNumber
    * @attr ref android.R.styleable#TextView_inputMethod
    * @attr ref android.R.styleable#TextView_capitalize
    * @attr ref android.R.styleable#TextView_autoText
    */
public final KeyListener getKeyListener (){
	return mInputView.getKeyListener();
}
 
源代码17 项目: MDPreference   文件: EditText.java
/**
    * Sets the key listener to be used with this TextView.  This can be null
    * to disallow user input.  Note that this method has significant and
    * subtle interactions with soft keyboards and other input method:
    * see {@link KeyListener#getInputType() KeyListener.getContentType()}
    * for important details.  Calling this method will replace the current
    * content type of the text view with the content type returned by the
    * key listener.
    * <p>
    * Be warned that if you want a TextView with a key listener or movement
    * method not to be focusable, or if you want a TextView without a
    * key listener or movement method to be focusable, you must call
    * {@link #setFocusable} again after calling this to get the focusability
    * back the way you want it.
    *
    * @attr ref android.R.styleable#TextView_numeric
    * @attr ref android.R.styleable#TextView_digits
    * @attr ref android.R.styleable#TextView_phoneNumber
    * @attr ref android.R.styleable#TextView_inputMethod
    * @attr ref android.R.styleable#TextView_capitalize
    * @attr ref android.R.styleable#TextView_autoText
    */
public void setKeyListener (KeyListener input){
	mInputView.setKeyListener(input);
}
 
源代码18 项目: AndroidMaterialValidation   文件: EditText.java
/**
 * @return the current key listener for this TextView. This will frequently be null for
 * non-EditText TextViews.
 */
public final KeyListener getKeyListener() {
    return getView().getKeyListener();
}
 
源代码19 项目: AndroidMaterialValidation   文件: EditText.java
/**
 * Sets the key listener to be used with this TextView. This can be null to disallow user input.
 * Note that this method has significant and subtle interactions with soft keyboards and other
 * input method: see {@link KeyListener#getInputType() KeyListener.getContentType()} for
 * important details. Calling this method will replace the current content type of the text view
 * with the content type returned by the key listener. <p> Be warned that if you want a TextView
 * with a key listener or movement method not to be focusable, or if you want a TextView without
 * a key listener or movement method to be focusable, you must call {@link #setFocusable} again
 * after calling this to get the focusability back the way you want it.
 */
public final void setKeyListener(final KeyListener input) {
    getView().setKeyListener(input);
}
 
源代码20 项目: material   文件: EditText.java
/**
    * @return the current key listener for this TextView.
    * This will frequently be null for non-EditText TextViews.
    *
    * @attr ref android.R.styleable#TextView_numeric
    * @attr ref android.R.styleable#TextView_digits
    * @attr ref android.R.styleable#TextView_phoneNumber
    * @attr ref android.R.styleable#TextView_inputMethod
    * @attr ref android.R.styleable#TextView_capitalize
    * @attr ref android.R.styleable#TextView_autoText
    */
public final KeyListener getKeyListener (){
	return mInputView.getKeyListener();
}
 
源代码21 项目: material   文件: EditText.java
/**
    * Sets the key listener to be used with this TextView.  This can be null
    * to disallow user input.  Note that this method has significant and
    * subtle interactions with soft keyboards and other input method:
    * see {@link KeyListener#getInputType() KeyListener.getContentType()}
    * for important details.  Calling this method will replace the current
    * content type of the text view with the content type returned by the
    * key listener.
    * <p>
    * Be warned that if you want a TextView with a key listener or movement
    * method not to be focusable, or if you want a TextView without a
    * key listener or movement method to be focusable, you must call
    * {@link #setFocusable} again after calling this to get the focusability
    * back the way you want it.
    *
    * @attr ref android.R.styleable#TextView_numeric
    * @attr ref android.R.styleable#TextView_digits
    * @attr ref android.R.styleable#TextView_phoneNumber
    * @attr ref android.R.styleable#TextView_inputMethod
    * @attr ref android.R.styleable#TextView_capitalize
    * @attr ref android.R.styleable#TextView_autoText
    */
public void setKeyListener (KeyListener input){
	mInputView.setKeyListener(input);
}
 
 类所在包
 类方法
 同包方法