Java Code Examples for android.support.design.widget.TextInputEditText#setInputType()

The following examples show how to use android.support.design.widget.TextInputEditText#setInputType() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbiIntegerViewHolder.java    From EosCommander with MIT License 5 votes vote down vote up
@Override
protected View getItemView(LayoutInflater layoutInflater, ViewGroup parentView, String label ) {
    ViewGroup vg = (ViewGroup)layoutInflater.inflate( R.layout.label_with_int, parentView, false );
    setItemViewLabel( vg, label );

    // add TYPE_NUMBER_FLAG_SIGNED when type is "signed int".
    TextInputEditText tie = vg.findViewById( R.id.et_input);
    tie.setInputType( getTypeName().startsWith( TYPE_PREFIX_FOR_SIGNED ) ?
            ( InputType.TYPE_CLASS_NUMBER | TYPE_NUMBER_FLAG_SIGNED) : InputType.TYPE_CLASS_NUMBER );

    return vg;
}
 
Example 2
Source File: AbiBigIntegerViewHolder.java    From EosCommander with MIT License 5 votes vote down vote up
@Override
protected View getItemView(LayoutInflater layoutInflater, ViewGroup parentView, String label ) {
    ViewGroup container = (ViewGroup)super.getItemView( layoutInflater, parentView, label);

    // add TYPE_NUMBER_FLAG_SIGNED when type is "signed int".
    TextInputEditText tie = container.findViewById( R.id.et_input);
    tie.setInputType( getTypeName().startsWith( TYPE_PREFIX_FOR_SIGNED ) ?
            ( InputType.TYPE_CLASS_NUMBER | TYPE_NUMBER_FLAG_SIGNED) : InputType.TYPE_CLASS_NUMBER );

    return container;
}
 
Example 3
Source File: FloatingEditText.java    From FloatingEditText with Apache License 2.0 4 votes vote down vote up
private void setup(Context context, AttributeSet attrs, int defStyleAttr) {
    editText = new TextInputEditText(context);

    if (attrs != null) {
        TypedArray ta = context.getTheme().obtainStyledAttributes(attrs, R.styleable.FloatingEditText, 0, 0);

        if (ta.hasValue(R.styleable.FloatingEditText_android_text)) {
            editText.setText(ta.getString(R.styleable.FloatingEditText_android_text));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_textAllCaps)) {
            editText.setAllCaps(ta.getBoolean(R.styleable.FloatingEditText_android_textAllCaps, false));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_textColor)) {
            editText.setTextColor(ta.getColor(R.styleable.FloatingEditText_android_textColor, 0));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_textSize)) {
            editText.setTextSize(TypedValue.COMPLEX_UNIT_PX, ta.getDimensionPixelSize(R.styleable.FloatingEditText_android_textSize, 0));
        }

        int textStyle = Typeface.NORMAL;
        if (ta.hasValue(R.styleable.FloatingEditText_android_textStyle)) {
            textStyle = ta.getInt(R.styleable.FloatingEditText_android_textStyle, Typeface.NORMAL);
        }

        String fontFamily = "sans-serif";
        if (ta.hasValue(R.styleable.FloatingEditText_android_fontFamily)) {
            fontFamily = ta.getString(R.styleable.FloatingEditText_android_fontFamily);
        }

        editText.setTypeface(Typeface.create(fontFamily, textStyle));

        if (ta.hasValue(R.styleable.FloatingEditText_android_inputType)) {
            editText.setInputType(ta.getInt(R.styleable.FloatingEditText_android_inputType, -1));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_imeOptions)) {
            editText.setImeOptions(ta.getInt(R.styleable.FloatingEditText_android_imeOptions, -1));
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_maxLength)) {
            editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(ta.getInt(R.styleable.FloatingEditText_android_maxLength, 0))});
        }

        if (ta.hasValue(R.styleable.FloatingEditText_android_maxLines)) {
            editText.setMaxLines(ta.getInt(R.styleable.FloatingEditText_android_maxLines,1));
        }

        ta.recycle();
    }

    addView(editText);
}