当前位置: 首页>>代码示例>>Java>>正文


Java InputType.TYPE_CLASS_NUMBER属性代码示例

本文整理汇总了Java中android.text.InputType.TYPE_CLASS_NUMBER属性的典型用法代码示例。如果您正苦于以下问题:Java InputType.TYPE_CLASS_NUMBER属性的具体用法?Java InputType.TYPE_CLASS_NUMBER怎么用?Java InputType.TYPE_CLASS_NUMBER使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在android.text.InputType的用法示例。


在下文中一共展示了InputType.TYPE_CLASS_NUMBER属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: autoValidator

/**
 * Get validator automatically according to EditText inputType
 */
private void autoValidator() {
    if(mEditText != null) {
        switch (mEditText.getInputType()) {
            case InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS:
                mValidatorNumber = IS_EMAIL;
                break;
            case InputType.TYPE_CLASS_PHONE:
                mValidatorNumber = IS_PHONE_NUMBER;
                break;
            case InputType.TYPE_CLASS_NUMBER:
                mValidatorNumber = IS_NUMERIC;
                break;
        }
    }
}
 
开发者ID:pchmn,项目名称:AndroidVerify,代码行数:18,代码来源:InputValidator.java

示例2: getType

private int getType(EditType editType) {
    int type;
    switch (editType) {
        case phone:
            type = InputType.TYPE_CLASS_PHONE;
            break;
        case number:
            type = InputType.TYPE_CLASS_NUMBER;
            break;
        case numberDecimal:
            type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_FLAG_DECIMAL;
            break;
        case textPassword:
            type = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
            break;
        case numberPassword:
            type = InputType.TYPE_CLASS_NUMBER | InputType.TYPE_NUMBER_VARIATION_PASSWORD;
            break;
        default:
            type = InputType.TYPE_CLASS_TEXT;
    }
    return type;
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:23,代码来源:EditTextWatcher.java

示例3: setInputType

@Override
public void setInputType(int type) {
    if (type == -1) {
        type = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS | InputType.TYPE_TEXT_VARIATION_PASSWORD;
    }

    if (type == InputType.TYPE_CLASS_NUMBER ||
            type == InputType.TYPE_NUMBER_FLAG_SIGNED ||
            type == InputType.TYPE_NUMBER_FLAG_DECIMAL ||
            type == InputType.TYPE_CLASS_PHONE) {
        final String symbolExceptions = getSymbolExceptions();
        this.setKeyListener(DigitsKeyListener.getInstance("0123456789." + symbolExceptions));
    } else {
        super.setInputType(type);
    }
}
 
开发者ID:msayan,项目名称:star-dns-changer,代码行数:16,代码来源:MaskedEditText.java

示例4: init

private void init() {
    if (getInputType() == InputType.TYPE_CLASS_NUMBER) { // if inputType="number", it can't insert separator.
        setInputType(InputType.TYPE_CLASS_PHONE);
    }

    mTextWatcher = new MyTextWatcher();
    this.addTextChangedListener(mTextWatcher);
    mRightMarkerDrawable = getCompoundDrawables()[2];
    if (customizeMarkerEnable && mRightMarkerDrawable != null) {
        setCompoundDrawables(getCompoundDrawables()[0], getCompoundDrawables()[1],
                null, getCompoundDrawables()[3]);
        setHasNoSeparator(true);
    }
    if (mRightMarkerDrawable == null) { // didn't customize Marker
        mRightMarkerDrawable = ContextCompat.getDrawable(getContext(), R.mipmap.indicator_input_error);
        DrawableCompat.setTint(mRightMarkerDrawable, getCurrentHintTextColor());
        if (mRightMarkerDrawable != null) {
            mRightMarkerDrawable.setBounds(0, 0, mRightMarkerDrawable.getIntrinsicWidth(),
                    mRightMarkerDrawable.getIntrinsicHeight());
        }
    }

    setOnFocusChangeListener(new OnFocusChangeListener() {
        @Override
        public void onFocusChange(View v, boolean hasFocus) {
            hasFocused = hasFocus;
            markerFocusChangeLogic();
            iOSFocusChangeLogic();
        }
    });

    if (iOSStyleEnable) {
        initiOSObjects();
    }
    if (disableEmoji) {
        setFilters(new InputFilter[]{new EmojiExcludeFilter()});
    }
}
 
开发者ID:zuoweitan,项目名称:Hitalk,代码行数:38,代码来源:XEditText.java

示例5: getKeyboardMode

private static int getKeyboardMode(final EditorInfo editorInfo) {
    final int inputType = editorInfo.inputType;
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;

    switch (inputType & InputType.TYPE_MASK_CLASS) {
    case InputType.TYPE_CLASS_NUMBER:
        return KeyboardId.MODE_NUMBER;
    case InputType.TYPE_CLASS_DATETIME:
        switch (variation) {
        case InputType.TYPE_DATETIME_VARIATION_DATE:
            return KeyboardId.MODE_DATE;
        case InputType.TYPE_DATETIME_VARIATION_TIME:
            return KeyboardId.MODE_TIME;
        default: // InputType.TYPE_DATETIME_VARIATION_NORMAL
            return KeyboardId.MODE_DATETIME;
        }
    case InputType.TYPE_CLASS_PHONE:
        return KeyboardId.MODE_PHONE;
    case InputType.TYPE_CLASS_TEXT:
        if (InputTypeUtils.isEmailVariation(variation)) {
            return KeyboardId.MODE_EMAIL;
        } else if (variation == InputType.TYPE_TEXT_VARIATION_URI) {
            return KeyboardId.MODE_URL;
        } else if (variation == InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
            return KeyboardId.MODE_IM;
        } else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
            return KeyboardId.MODE_TEXT;
        } else {
            return KeyboardId.MODE_TEXT;
        }
    default:
        return KeyboardId.MODE_TEXT;
    }
}
 
开发者ID:rkkr,项目名称:simple-keyboard,代码行数:34,代码来源:KeyboardLayoutSet.java

示例6: setInputType

private void setInputType() {

        /** Checks the preferences for the default keyboard layout.
         * If qwerty, we start out whether in qwerty or numbers, depending on the input type.
         * */

        EditorInfo attribute = getCurrentInputEditorInfo();

        if (PreferenceManager.getDefaultSharedPreferences(getBaseContext()).getString("start", "1").equals("1")) {
            switch (attribute.inputType & InputType.TYPE_MASK_CLASS) {
                case InputType.TYPE_CLASS_NUMBER:
                case InputType.TYPE_CLASS_DATETIME:
                case InputType.TYPE_CLASS_PHONE:
                    currentKeyboard = new LatinKeyboard(this, R.xml.numbers);
                    break;
                case InputType.TYPE_CLASS_TEXT:
                    int webInputType = attribute.inputType & InputType.TYPE_MASK_VARIATION;

                    if (webInputType == InputType.TYPE_TEXT_VARIATION_URI ||
                            webInputType == InputType.TYPE_TEXT_VARIATION_WEB_EDIT_TEXT ||
                            webInputType == InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS
                            || webInputType == InputType.TYPE_TEXT_VARIATION_WEB_EMAIL_ADDRESS) {
                        currentKeyboard = new LatinKeyboard(this, qwertyKeyboardID);
                    } else {
                        currentKeyboard = new LatinKeyboard(this, qwertyKeyboardID);
                    }

                    break;

                default:
                    currentKeyboard = new LatinKeyboard(this, qwertyKeyboardID);
                    break;
            }
        } else {
            setDefaultKeyboard();
        }
        if (kv != null) {
            kv.setKeyboard(currentKeyboard);
        }
    }
 
开发者ID:VladThodo,项目名称:behe-keyboard,代码行数:40,代码来源:PCKeyboard.java

示例7: getInputType

private int getInputType(String type) {
  int inputType;
  switch (type) {
    case Constants.Value.TEXT:
      inputType = InputType.TYPE_CLASS_TEXT;
      break;
    case Constants.Value.DATE:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.DATETIME:
      inputType = InputType.TYPE_CLASS_DATETIME;
      break;
    case Constants.Value.EMAIL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_EMAIL_ADDRESS;
      break;
    case Constants.Value.PASSWORD:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_PASSWORD;
      getHostView().setTransformationMethod(PasswordTransformationMethod.getInstance());
      break;
    case Constants.Value.TEL:
      inputType = InputType.TYPE_CLASS_PHONE;
      break;
    case Constants.Value.TIME:
      inputType = InputType.TYPE_NULL;
      getHostView().setFocusable(false);
      break;
    case Constants.Value.URL:
      inputType = InputType.TYPE_CLASS_TEXT | InputType.TYPE_TEXT_VARIATION_URI;
      break;
    case Constants.Value.NUMBER:
      inputType = InputType.TYPE_CLASS_NUMBER;
      break;
    default:
      inputType = InputType.TYPE_CLASS_TEXT;
  }
  return inputType;
}
 
开发者ID:weexext,项目名称:ucar-weex-core,代码行数:38,代码来源:AbstractEditComponent.java

示例8: onStartInput

@Override
public void onStartInput(EditorInfo info, boolean restarting) {
    try {
        //Check the input text accepts multi-lines or not
        Common.isInputTextSingleLine = 0 == (info.inputType & InputType.TYPE_TEXT_FLAG_MULTI_LINE);
        Common.isNumericInputText = 2 == (info.inputType & InputType.TYPE_CLASS_NUMBER);
        super.onStartInputView(info, restarting);
    } catch (Exception e) {
        e.printStackTrace();
    }
}
 
开发者ID:MohammadAlBanna,项目名称:Swift-Braille-Soft-keyboard,代码行数:11,代码来源:BrailleIME.java

示例9: getKeyboardMode

/**
 * 获取输入法键盘类型.
 */
private int getKeyboardMode(final EditorInfo editorInfo) {
    if (editorInfo == null) {
        return KeyBoardID.MODE_TEXT;
    }
    //
    final int inputType = editorInfo.inputType;
    final int variation = inputType & InputType.TYPE_MASK_VARIATION;
    // 根据 eidttext inputtype 返回软键盘类型.
    switch (inputType & InputType.TYPE_MASK_CLASS) {
        case InputType.TYPE_CLASS_NUMBER: // 数字键盘.
            // return KeyBoardID.MODE_NUMBER;
        case InputType.TYPE_CLASS_PHONE: // 显示符号键盘. phone拨号.
            // return KeyBoardID.MODE_PHONE;
        case InputType.TYPE_CLASS_DATETIME: // 日期,时间. 文本输入框要求输入数字或日期时.
            switch (variation) {
                case InputType.TYPE_DATETIME_VARIATION_DATE: // 多一个 "/"
                    return KeyBoardID.MODE_DATE;
                case InputType.TYPE_DATETIME_VARIATION_TIME: // 多一个 ":"
                    return KeyBoardID.MODE_TIME;
                default: // InputType.TYPE_DATETIME_VARIATION_NORMAL
                    return KeyBoardID.MODE_DATETIME; // 多两个 "/",":"
            }
        case InputType.TYPE_CLASS_TEXT: // 显示输入字母的软键盘.
            if (KeyBoardUtils.isEmailVariation(variation)) {
                return KeyBoardID.MODE_EMAIL;
            } else if (variation == InputType.TYPE_TEXT_VARIATION_URI) {
                return KeyBoardID.MODE_URL;
            } else if (variation == InputType.TYPE_TEXT_VARIATION_SHORT_MESSAGE) {
                return KeyBoardID.MODE_IM;
            } else if (variation == InputType.TYPE_TEXT_VARIATION_FILTER) {
                return KeyBoardID.MODE_TEXT;
            } else {
                return KeyBoardID.MODE_TEXT;
            }
        default:
            return KeyBoardID.MODE_TEXT;
    }
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:41,代码来源:EmojiIME.java

示例10: toInputClassString

private static String toInputClassString(final int inputClass) {
    switch (inputClass) {
    case InputType.TYPE_CLASS_TEXT:
        return "TYPE_CLASS_TEXT";
    case InputType.TYPE_CLASS_PHONE:
        return "TYPE_CLASS_PHONE";
    case InputType.TYPE_CLASS_NUMBER:
        return "TYPE_CLASS_NUMBER";
    case InputType.TYPE_CLASS_DATETIME:
        return "TYPE_CLASS_DATETIME";
    default:
        return String.format("unknownInputClass<0x%08x>", inputClass);
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:14,代码来源:InputAttributes.java

示例11: onCreateInputConnection

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {

    outAttrs.inputType = InputType.TYPE_CLASS_NUMBER;
    outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
    outAttrs.initialSelStart = 0;

    return editCodeInputConnection;
}
 
开发者ID:Onum,项目名称:EditCodeView,代码行数:9,代码来源:EditCodeView.java

示例12: toVariationString

private static String toVariationString(final int inputClass, final int variation) {
    switch (inputClass) {
    case InputType.TYPE_CLASS_TEXT:
        return toTextVariationString(variation);
    case InputType.TYPE_CLASS_NUMBER:
        return toNumberVariationString(variation);
    case InputType.TYPE_CLASS_DATETIME:
        return toDatetimeVariationString(variation);
    default:
        return "";
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:12,代码来源:InputAttributes.java

示例13: formatNumberTypes

private void formatNumberTypes(CharSequence text) {
    if (inputType == InputType.TYPE_CLASS_NUMBER) {
        etValue.removeTextChangedListener(this);
        if (!text.toString().equals(current)) {

            String cleanString = text.toString().replaceAll("[,.]", "");
            if (TextUtils.isEmpty(cleanString)) {
                etValue.setText("");
                etValue.setHint(hintText);
                return;
            }
            double parsed = Double.parseDouble(cleanString);
            if (parsed == 0) {
                etValue.setText("");
                etValue.setHint(hintText);
            } else {
                String formatted =
                        mContext.getString(R.string.number_format_text, parsed / 100);

                current = formatted;
                etValue.setText(formatted);
                etValue.setSelection(formatted.length());
            }
        }
        etValue.addTextChangedListener(this);
    }
}
 
开发者ID:riteshakya037,项目名称:Subs,代码行数:27,代码来源:MaskEditText.java

示例14: onCreateInputConnection

@Override
public InputConnection onCreateInputConnection(EditorInfo outAttrs) {
    outAttrs.inputType = InputType.TYPE_CLASS_NUMBER;// inputType is number
    outAttrs.imeOptions = EditorInfo.IME_ACTION_DONE;
    return new NumInputConnection(this, false);
}
 
开发者ID:VigorousLiang,项目名称:PWEditText-SafeKeyboard,代码行数:6,代码来源:SafePswText.java

示例15: setAuthType

/**
 * 设置验证类型
 *
 * @param authType {@link AuthType}
 */
public void setAuthType(AuthType authType)
{
    if(this.authType == authType)
    {
        return;
    }

    /**
     * 在 {@link #authType} 值被改变之前,判断是不是需要清空文本.
     */
    boolean needClearText = needClearText(authType);

    this.authType = authType;

    int inputType = InputType.TYPE_CLASS_NUMBER;
    switch(this.authType)
    {
        case NUMBER:
            inputType = InputType.TYPE_CLASS_NUMBER;
            break;
        case PASSWORD:
            inputType = InputType.TYPE_TEXT_VARIATION_PASSWORD;
            break;
        case VISIBLE_PASSWORD:
            inputType = InputType.TYPE_TEXT_VARIATION_VISIBLE_PASSWORD;
            break;
        case NUMBER_PASSWORD:
            if(Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB)
            {
                inputType = InputType.TYPE_NUMBER_VARIATION_PASSWORD;
            }
            break;
        case DEFAULT:
            /**
             * 这里的 InputType 不设置为 {@link InputType.TYPE_NULL},是因为设置这个后,
             * {@link AuthEditText} 的点击事件失效
             */
            inputType = InputType.TYPE_TEXT_FLAG_NO_SUGGESTIONS;
            break;
    }
    etInput.setInputType(inputType);

    if(needClearText)
    {
        clearText();
    }

    /**
     * 输入类型变化时,需要手动更改文本。直接调用 {@link TextView#setInputType(int)} 没有作用.
     */
    for(int i = 0; i < list.size(); i++)
    {
        if(string.length() > i)
        {
            fillTextByIndex(i);
        }
    }
}
 
开发者ID:Ayvytr,项目名称:EasyAndroid,代码行数:63,代码来源:AuthEditText.java


注:本文中的android.text.InputType.TYPE_CLASS_NUMBER属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。