Example usage for android.content.res TypedArray getInt

List of usage examples for android.content.res TypedArray getInt

Introduction

In this page you can find the example usage for android.content.res TypedArray getInt.

Prototype

public int getInt(@StyleableRes int index, int defValue) 

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:com.pranavpandey.smallapp.view.ColoredTextView.java

public ColoredTextView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorAtrributes);
    mColorType = a.getInt(R.styleable.ColorAtrributes_colorType, 0);
    mBackgroundAware = a.getBoolean(R.styleable.ColorAtrributes_backgroundAware, false);
    mContrastWith = a.getColor(R.styleable.ColorAtrributes_contrastWith,
            ContextCompat.getColor(getContext(), R.color.sas_default_color_contrast_with));
    a.recycle();/*w  w  w.  j a  v  a 2s. co  m*/

    init();
}

From source file:com.pranavpandey.smallapp.view.ColoredTextView.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ColoredTextView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorAtrributes);
    mColorType = a.getInt(R.styleable.ColorAtrributes_colorType, 0);
    mBackgroundAware = a.getBoolean(R.styleable.ColorAtrributes_backgroundAware, false);
    mContrastWith = a.getColor(R.styleable.ColorAtrributes_contrastWith,
            ContextCompat.getColor(getContext(), R.color.sas_default_color_contrast_with));
    a.recycle();/* ww  w  .j  av  a  2 s  .com*/

    init();
}

From source file:com.pranavpandey.smallapp.view.ColoredImageView.java

public ColoredImageView(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorAtrributes);
    mColorType = a.getInt(R.styleable.ColorAtrributes_colorType, 0);
    mBackgroundAware = a.getBoolean(R.styleable.ColorAtrributes_backgroundAware, false);
    mContrastWith = a.getColor(R.styleable.ColorAtrributes_contrastWith,
            ContextCompat.getColor(getContext(), R.color.sas_default_color_contrast_with));
    a.recycle();/*from w w w.ja v  a  2s.c o m*/

    init();
}

From source file:com.pranavpandey.smallapp.view.ColoredImageView.java

@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public ColoredImageView(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ColorAtrributes);
    mColorType = a.getInt(R.styleable.ColorAtrributes_colorType, 0);
    mBackgroundAware = a.getBoolean(R.styleable.ColorAtrributes_backgroundAware, false);
    mContrastWith = a.getColor(R.styleable.ColorAtrributes_contrastWith,
            ContextCompat.getColor(getContext(), R.color.sas_default_color_contrast_with));
    a.recycle();/*from  www  . j a  v a 2 s. c  o m*/

    init();
}

From source file:com.commonsware.cwac.colormixer.ColorMixer.java

private void initMixer(AttributeSet attrs) {
    if (isInEditMode()) {
        return;/*  w  ww  . j  ava2 s  . c o  m*/
    }

    LayoutInflater inflater = null;

    if (getContext() instanceof Activity) {
        inflater = ((Activity) getContext()).getLayoutInflater();
    } else {
        inflater = LayoutInflater.from(getContext());
    }

    inflater.inflate(R.layout.cwac_colormixer_main, this, true);

    swatch = findViewById(R.id.swatch);

    red = (SeekBar) findViewById(R.id.red);
    red.setMax(0xFF);
    red.setOnSeekBarChangeListener(onMix);

    green = (SeekBar) findViewById(R.id.green);
    green.setMax(0xFF);
    green.setOnSeekBarChangeListener(onMix);

    blue = (SeekBar) findViewById(R.id.blue);
    blue.setMax(0xFF);
    blue.setOnSeekBarChangeListener(onMix);

    if (attrs != null) {
        int[] styleable = R.styleable.ColorMixer;
        TypedArray a = getContext().obtainStyledAttributes(attrs, styleable, 0, 0);

        setColor(a.getInt(R.styleable.ColorMixer_cwac_colormixer_color, 0xFFA4C639));
        a.recycle();
    }
}

From source file:com.android.calculator2.CalculatorPadLayout.java

public CalculatorPadLayout(Context context, AttributeSet attrs, int defStyle) {
    super(context, attrs, defStyle);

    final TypedArray a = context.obtainStyledAttributes(attrs,
            new int[] { android.R.attr.rowCount, android.R.attr.columnCount }, defStyle, 0);
    mRowCount = a.getInt(0, 1);
    mColumnCount = a.getInt(1, 1);//from w w w . j  ava  2 s .  c o  m

    a.recycle();
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticButton.java

private void setTypeArray(TypedArray typedArray) {
    GradientDrawable bgShape = (GradientDrawable) view.getBackground();

    round = typedArray.getInt(R.styleable.ElasticButton_button_round, round);
    bgShape.setCornerRadius(round);//from  w w w.  j ava 2s.  co m

    color = typedArray.getInt(R.styleable.ElasticButton_button_backgroundColor, color);
    bgShape.setColor(color);

    scale = typedArray.getFloat(R.styleable.ElasticButton_button_scale, scale);

    duration = typedArray.getInt(R.styleable.ElasticButton_button_duration, duration);

    labelText = typedArray.getString(R.styleable.ElasticButton_button_labelText);
    view.setText(labelText);

    labelColor = typedArray.getInt(R.styleable.ElasticButton_button_labelColor, labelColor);
    view.setTextColor(labelColor);

    labelSize = typedArray.getInt(R.styleable.ElasticButton_button_labelSize, labelSize);
    view.setTextSize(labelSize);

    labelStyle = typedArray.getInt(R.styleable.ElasticButton_button_labelStyle, labelStyle);

    if (labelStyle == 0)
        view.setTypeface(null, Typeface.NORMAL);
    else if (labelStyle == 1)
        view.setTypeface(null, Typeface.BOLD);
    else if (labelStyle == 2)
        view.setTypeface(null, Typeface.ITALIC);
}

From source file:com.flan.stock.view.NewsTabView.java

public NewsTabView(Context context, AttributeSet attrs) {
    super(context, attrs);

    //this.context = context;

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.animationTabWidget);
    currentTab = typedArray.getInt(R.styleable.animationTabWidget_current_index, 0);
    typedArray.recycle();// w  ww.  j a va2s  .  c  o  m

    inflate(context, R.layout.layout_news_tabview, this);

    img_cursor = (ImageView) this.findViewById(R.id.tag_img_cursor);

    tv_tag1 = (TextView) this.findViewById(R.id.tv_tag1);
    tv_tag2 = (TextView) this.findViewById(R.id.tv_tag2);
    tv_tag3 = (TextView) this.findViewById(R.id.tv_tag3);
    tv_tag4 = (TextView) this.findViewById(R.id.tv_tag4);
    tv_tag5 = (TextView) this.findViewById(R.id.tv_tag5);

    tv_tag1.setOnClickListener(this);
    tv_tag2.setOnClickListener(this);
    tv_tag3.setOnClickListener(this);
    tv_tag4.setOnClickListener(this);
    tv_tag5.setOnClickListener(this);

    initDefaultIndex();
}

From source file:com.flan.stock.view.AnimationTabWidget.java

public AnimationTabWidget(Context context, AttributeSet attrs) {
    super(context, attrs);

    //this.context = context;

    TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.animationTabWidget);
    currentTab = typedArray.getInt(R.styleable.animationTabWidget_current_index, 0);
    typedArray.recycle();/*  w  ww. java 2 s  .co  m*/

    inflate(context, R.layout.layout_animation_tab_widget, this);

    img_cursor = (ImageView) this.findViewById(R.id.tag_img_cursor);

    tv_tag1 = (TextView) this.findViewById(R.id.tv_tag1);
    tv_tag2 = (TextView) this.findViewById(R.id.tv_tag2);
    tv_tag3 = (TextView) this.findViewById(R.id.tv_tag3);
    tv_tag4 = (TextView) this.findViewById(R.id.tv_tag4);
    tv_tag5 = (TextView) this.findViewById(R.id.tv_tag5);

    tv_tag1.setOnClickListener(this);
    tv_tag2.setOnClickListener(this);
    tv_tag3.setOnClickListener(this);
    tv_tag4.setOnClickListener(this);
    tv_tag5.setOnClickListener(this);

    initDefaultIndex();
}

From source file:com.skydoves.elasticviewsexample.ElasticVIews.ElasticCheckButton.java

private void setTypeArray(TypedArray typedArray) {
    GradientDrawable bgShape = (GradientDrawable) view.getBackground();

    round = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_round, round);
    bgShape.setCornerRadius(round);/*w w w. j av a2s  .  c  om*/

    color = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_backgroundColor, color);
    bgShape.setColor(color);

    scale = typedArray.getFloat(R.styleable.ElasticCheckButton_checkbutton_scale, scale);

    duration = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_duration, duration);

    labelText = typedArray.getString(R.styleable.ElasticCheckButton_checkbutton_labelText);
    view.setText(labelText);

    labelColor = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelColor, labelColor);
    view.setTextColor(labelColor);

    labelSize = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelSize, labelSize);
    view.setTextSize(labelSize);

    labelStyle = typedArray.getInt(R.styleable.ElasticCheckButton_checkbutton_labelStyle, labelStyle);

    if (labelStyle == 0)
        view.setTypeface(null, Typeface.NORMAL);
    else if (labelStyle == 1)
        view.setTypeface(null, Typeface.BOLD);
    else if (labelStyle == 2)
        view.setTypeface(null, Typeface.ITALIC);

    alpha = typedArray.getFloat(R.styleable.ElasticCheckButton_checkbutton_alpha, alpha);

    checked = typedArray.getBoolean(R.styleable.ElasticCheckButton_checkbutton_ischecked, checked);
    if (checked)
        view.setAlpha(alpha);
}