Example usage for android.content.res TypedArray getInteger

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

Introduction

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

Prototype

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

Source Link

Document

Retrieve the integer value for the attribute at index.

Usage

From source file:it.scoppelletti.mobilepower.preference.SeekBarPreference.java

/**
 * Restituisce il valore di default impostato via XML.
 * //w  w  w . ja va  2s .co  m
 * @param  attrs Attributi impostati.
 * @param  index Indice del valore di default.
 * @return       Valore di default.
 */
@Override
protected Object onGetDefaultValue(TypedArray attrs, int index) {
    return attrs.getInteger(index, 0);
}

From source file:de.aw.monma.views.SpinnerAccount.java

private void init(Context context, AttributeSet attrs) {
    if (!isInEditMode()) {
        mLoaderManager = ((AppCompatActivity) context).getSupportLoaderManager();
        projection = new String[] { _id, column_accountname };
        selectionNotAusgeblendet = " NOT " + column_ausgeblendet;
        if (mModus == null) {
            TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SpinnerAccount);
            try {
                int modus = a.getInteger(R.styleable.SpinnerAccount_modus, Modus.Cash.ordinal());
                mModus = Modus.values()[modus];
            } finally {
                a.recycle();//from  w w  w .  j  ava 2s. c om
            }
        }
        int[] adapterRowViews = new int[] { android.R.id.text1 };
        String[] adapterCols = new String[] { column_accountname };
        adapter = new SimpleCursorAdapter(getContext(), android.R.layout.simple_spinner_item, null, adapterCols,
                adapterRowViews, 0);
        adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
        setAdapter(adapter);
        super.setOnItemSelectedListener(this);
        if (getVisibility() == VISIBLE) {
            startOrRestartLoader(getId());
        }
    }
}

From source file:com.lovejoy777sarootool.rootool.BrowserActivity.java

private void setupDrawer() {
    final TypedArray array = obtainStyledAttributes(new int[] { R.attr.themeId });
    final int themeId = array.getInteger(0, SimpleExplorer.THEME_ID_LIGHT);
    array.recycle();/*  w w w .  j a  v a  2  s.com*/

    mDrawer = (ListView) findViewById(R.id.left_drawer);

    // Set shadow of navigation drawer
    mDrawerLayout = (DrawerLayout) findViewById(R.id.drawer_layout);
    mDrawerLayout.setDrawerShadow(R.drawable.drawer_shadow, GravityCompat.START);

    int icon = themeId == SimpleExplorer.THEME_ID_LIGHT ? R.drawable.holo_light_ic_drawer
            : R.drawable.holo_dark_ic_drawer;

    // Add Navigation Drawer to ActionBar
    mDrawerToggle = new ActionBarDrawerToggle(this, mDrawerLayout, icon, R.string.drawer_open,
            R.string.drawer_close) {

        @Override
        public void onDrawerOpened(View view) {
            super.onDrawerOpened(view);
            invalidateOptionsMenu();
        }

        @Override
        public void onDrawerClosed(View view) {
            super.onDrawerClosed(view);
            invalidateOptionsMenu();
        }
    };

    mDrawerLayout.setDrawerListener(mDrawerToggle);
}

From source file:paulscode.android.mupen64plusae.preference.SeekBarPreference.java

/**
 * Constructor/*  w w  w .  j a  v  a2s  .c  o  m*/
 *
 * @param context The {@link Context} this SeekBarPreference is being used in.
 * @param attrs   A collection of attributes, as found associated with a tag in an XML document.
 */
public SeekBarPreference(Context context, AttributeSet attrs) {
    super(context, attrs);

    // Get the attributes from the XML file, if provided
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SeekBarPreference);
    setMinValue(a.getInteger(R.styleable.SeekBarPreference_minimumValue, DEFAULT_MIN));
    setMaxValue(a.getInteger(R.styleable.SeekBarPreference_maximumValue, DEFAULT_MAX));
    setStepSize(a.getInteger(R.styleable.SeekBarPreference_stepSize, DEFAULT_STEP));
    setUnits(a.getString(R.styleable.SeekBarPreference_units));
    setSaveType(a.getString(R.styleable.SeekBarPreference_saveType));

    a.recycle();

    // Setup the layout
    setDialogLayoutResource(R.layout.seek_bar_preference);

    setOnPreferenceChangeListener(null);
}

From source file:com.ylsg365.pai.activity.view.SlidingTabLayout.java

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

    // Disable the Scroll Bar
    setHorizontalScrollBarEnabled(false);
    // Make sure that the Tab Strips fills this View
    setFillViewport(true);//from   w  w w.  ja  va  2s  . c  om

    mTitleOffset = (int) (TITLE_OFFSET_DIPS * getResources().getDisplayMetrics().density);

    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.SlidingTabLayout);
    tabCount = a.getInteger(R.styleable.SlidingTabLayout_tabCount, 1);
    tabTextColorNormal = a.getColor(R.styleable.SlidingTabLayout_tabTextColorNormal,
            getResources().getColor(R.color.black));
    tabTextColorChecked = a.getColor(R.styleable.SlidingTabLayout_tabTextColorChecked,
            getResources().getColor(R.color.purple));
    normalItemLineColor = a.getColor(R.styleable.SlidingTabLayout_normalItemLineColor,
            getResources().getColor(R.color.line_radio));
    selectedItemLineColor = a.getColor(R.styleable.SlidingTabLayout_selectedItemLineColor,
            getResources().getColor(R.color.purple));
    mTabStrip = new SlidingTabStrip(context, tabTextColorNormal, tabTextColorChecked, normalItemLineColor,
            selectedItemLineColor);
    addView(mTabStrip, LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);

    a.recycle();
}

From source file:com.twotoasters.jazzylistview.JazzyHelper.java

public JazzyHelper(Context context, AttributeSet attrs) {
    mAlreadyAnimatedItems = new HashSet<>();
    int transitionEffect = HELIX;
    int maxVelocity = 0;

    if (context != null && attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.JazzyListView);
        transitionEffect = a.getInteger(R.styleable.JazzyListView_effect, STANDARD);
        maxVelocity = a.getInteger(R.styleable.JazzyListView_max_velocity, MAX_VELOCITY_OFF);
        mOnlyAnimateNewItems = a.getBoolean(R.styleable.JazzyListView_only_animate_new_items, false);
        mOnlyAnimateOnFling = a.getBoolean(R.styleable.JazzyListView_only_animate_fling, false);
        mSimulateGridWithList = a.getBoolean(R.styleable.JazzyListView_simulate_grid_with_list, false);
        a.recycle();/* w w  w .  j av a2 s.c om*/
    }

    setTransitionEffect(transitionEffect);
    setMaxAnimationVelocity(maxVelocity);
}

From source file:ir.newway.jazzylistview.JazzyHelper.java

public JazzyHelper(Context context, AttributeSet attrs) {
    mInterpolator = new FastOutSlowInInterpolator();
    mAlreadyAnimatedItems = new HashSet<>();
    int transitionEffect = HELIX;
    int maxVelocity = 0;

    if (context != null && attrs != null) {
        TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.JazzyListView);
        transitionEffect = a.getInteger(R.styleable.JazzyListView_effect, STANDARD);
        maxVelocity = a.getInteger(R.styleable.JazzyListView_max_velocity, MAX_VELOCITY_OFF);
        mOnlyAnimateNewItems = a.getBoolean(R.styleable.JazzyListView_only_animate_new_items, false);
        mOnlyAnimateOnFling = a.getBoolean(R.styleable.JazzyListView_max_velocity, false);
        mSimulateGridWithList = a.getBoolean(R.styleable.JazzyListView_simulate_grid_with_list, false);
        a.recycle();//  www.j  a  va 2  s  .co  m
    }

    setTransitionEffect(transitionEffect);
    setMaxAnimationVelocity(maxVelocity);
}

From source file:com.github.rubensousa.stackview.StackView.java

public StackView(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    mViews = new ArrayList<>();
    mRandom = new Random();
    mHardwareAccelerationEnabled = true;
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.StackView, 0, 0);
    mSize = a.getInteger(R.styleable.StackView_stackview_size, 4);
    mHorizontalSpacing = a.getDimension(R.styleable.StackView_stackview_horizontalSpacing, 0f);
    mVerticalSpacing = a.getDimension(R.styleable.StackView_stackview_verticalSpacing, VERTICAL_SPACING);
    mElevationSpacing = a.getDimension(R.styleable.StackView_stackview_elevationSpacing, ELEVATION_SPACING);
    mItemMaxRotation = a.getInteger(R.styleable.StackView_stackview_rotationRandomMagnitude, 0);
    mScaleXFactor = a.getFloat(R.styleable.StackView_stackview_horizontalScalingFactor, SCALE_X_FACTOR);

    if (mScaleXFactor < 0 || mScaleXFactor > 1) {
        throw new IllegalArgumentException(
                "horizontalScalingFactor must be greater than 0" + "and less than 1");
    }//from w ww. j ava 2 s .  c  o m

    mCyclicLooping = a.getBoolean(R.styleable.StackView_stackview_cyclicLooping, false);
    mLayout = a.getResourceId(R.styleable.StackView_stackview_adapterLayout, 0);
    mAnimator = new StackDefaultAnimator();
    mAnimator.setStackView(this);
    mAnimator.setStackAnimationListener(this);
    a.recycle();

    setClipToPadding(false);
    setClipChildren(false);

    if (isInEditMode()) {
        addViews();
    }

}

From source file:nz.org.winters.android.custompreference.ColorPickerPreferenceCompat.java

private void initAttrs(AttributeSet attrs, int defStyle) {
    TypedArray a = getContext().getTheme().obtainStyledAttributes(attrs, R.styleable.ColorPickerPreference,
            defStyle, defStyle);/*  w w  w  .jav a2 s. c  o m*/

    try {
        mItemLayoutId = a.getResourceId(R.styleable.ColorPickerPreference_cal_itemLayout, mItemLayoutId);
        mNumColumns = a.getInteger(R.styleable.ColorPickerPreference_cal_numColumns, mNumColumns);
        int choicesResId = a.getResourceId(R.styleable.ColorPickerPreference_cal_choices,
                R.array.default_color_choice_values);
        if (choicesResId > 0) {
            String[] choices = a.getResources().getStringArray(choicesResId);
            mColorChoices = new int[choices.length];
            for (int i = 0; i < choices.length; i++) {
                mColorChoices[i] = Color.parseColor(choices[i]);
            }
        }

    } finally {
        a.recycle();
    }
    setWidgetLayoutResource(mItemLayoutId);
}

From source file:org.onebusaway.android.view.RealtimeIndicatorView.java

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

    // Get the custom attributes defined in XML
    TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.RealtimeIndicatorView, 0, 0);
    mFillColor = a.getColor(R.styleable.RealtimeIndicatorView_fillColor, mFillColor);
    mLineColor = a.getColor(R.styleable.RealtimeIndicatorView_lineColor, mLineColor);
    mDuration = a.getInteger(R.styleable.RealtimeIndicatorView_duration, mDuration);
    a.recycle();/*from   ww  w.  j  av a2  s.  com*/

    mFillPaint = new Paint();
    mFillPaint.setColor(mFillColor);
    mFillPaint.setStyle(Paint.Style.FILL);
    mFillPaint.setAntiAlias(true);

    mLinePaint = new Paint();
    mLinePaint.setStrokeWidth(3);
    mLinePaint.setColor(mLineColor);
    mLinePaint.setStyle(Paint.Style.STROKE);
    mLinePaint.setAntiAlias(true);

    setOnMeasureCallback();
    ensureInit();
}