List of usage examples for android.content.res TypedArray getInt
public int getInt(@StyleableRes int index, int defValue)
From source file:com.aprz.easy_iosched.ui.widget.CustomRatingBar.java
public CustomRatingBar(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray typedArray = context.getTheme().obtainStyledAttributes(attrs, R.styleable.CustomRatingBar, 0, 0); try {//from w w w . ja va 2 s .com mMaxRating = typedArray.getInt(R.styleable.CustomRatingBar_maxRating, DEFAULT_MAX_RATING); mFilledDrawable = typedArray.getDrawable(R.styleable.CustomRatingBar_filledDrawable); if (mFilledDrawable == null) { mFilledDrawable = ResourcesCompat.getDrawable(getResources(), DEFAULT_FILLED_DRAWABLE_ID, null); } mUnfilledDrawable = typedArray.getDrawable(R.styleable.CustomRatingBar_unfilledDrawable); if (mUnfilledDrawable == null) { mUnfilledDrawable = ResourcesCompat.getDrawable(getResources(), DEFAULT_UNFILLED_DRAWABLE_ID, null); } } finally { typedArray.recycle(); } setSaveEnabled(true); }
From source file:com.frozendevs.periodictable.view.ViewPagerTabs.java
@TargetApi(Build.VERSION_CODES.LOLLIPOP) public ViewPagerTabs(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); setFillViewport(true);/*w w w. jav a2 s . c o m*/ mSidePadding = getResources().getDimensionPixelOffset(R.dimen.tab_side_padding); final TypedArray a = context.obtainStyledAttributes(attrs, ATTRS); mTextSize = a.getDimensionPixelSize(0, 0); mTextStyle = a.getInt(1, 0); mTextColor = a.getColorStateList(2); a.recycle(); Resources.Theme theme = getContext().getTheme(); TypedValue typedValue = new TypedValue(); theme.resolveAttribute(R.attr.theme, typedValue, true); TypedArray typedArray = theme.obtainStyledAttributes(typedValue.resourceId, new int[] { R.attr.selectableItemBackground }); mTextBackground = typedArray.getResourceId(0, 0); typedArray.recycle(); mTabStrip = new ViewPagerTabStrip(context); addView(mTabStrip, new FrameLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.MATCH_PARENT)); if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { // enable shadow casting from view bounds setOutlineProvider(new ViewOutlineProvider() { @TargetApi(Build.VERSION_CODES.LOLLIPOP) @Override public void getOutline(View view, Outline outline) { outline.setRect(0, 0, view.getWidth(), view.getHeight()); } }); } }
From source file:com.chrisrenke.giv.GravityImageView.java
public GravityImageView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); matrix = new Matrix(); imageRect = new RectF(); // By nature of this view, only MATRIX is supported. If ya want to use other // scaleTypes, use an ImageView. setScaleType(MATRIX);// www . j a v a2 s .c om // Support for END/START. isRtl = ViewCompat.getLayoutDirection(this) == ViewCompat.LAYOUT_DIRECTION_RTL; // Early exit for whiziwiggin' it. if (isInEditMode()) return; TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.GravityImageView, // defStyleAttr, 0); imageScaleMode = a.getInt(R.styleable.GravityImageView_imageScaleMode, NONE); imageGravity = a.getInt(R.styleable.GravityImageView_imageGravity, CENTER); a.recycle(); }
From source file:com.github.andrewlord1990.materialandroid.component.textfield.PasswordEditText.java
private void loadToggleType(TypedArray attrs) { int type = attrs.getInt(R.styleable.MDPasswordEditText_md_password_toggle_type, TOGGLE_OPACITY); if (shownIcon == null) { setShownIcon();// w ww. j a v a2s . co m } if (hiddenIcon == null) { setHiddenIconFromType(type); } }
From source file:com.google.blockly.android.ui.BlockDrawerFragment.java
@Override public void onInflate(Context context, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(context, attrs, savedInstanceState); TypedArray a = context.getTheme().obtainStyledAttributes(attrs, R.styleable.BlockDrawerFragment, 0, 0); try {/* w w w.ja v a2 s.c o m*/ setCloseable(a.getBoolean(R.styleable.BlockDrawerFragment_closeable, mCloseable)); setScrollOrientation(a.getInt(R.styleable.BlockDrawerFragment_scrollOrientation, mScrollOrientation)); } finally { a.recycle(); } // Store values in arguments, so fragment resume works (no inflation during resume). Bundle args = getArguments(); if (args == null) { setArguments(args = new Bundle()); } args.putBoolean(ARG_CLOSEABLE, mCloseable); args.putInt(ARG_SCROLL_ORIENTATION, mScrollOrientation); }
From source file:com.givewaygames.transition.TransitionInflater.java
private Transition loadTransition(Transition transition, AttributeSet attrs) throws Resources.NotFoundException { TypedArray a = mContext.obtainStyledAttributes(attrs, R.styleable.Transition); long duration = a.getInt(R.styleable.Transition_duration, -1); if (duration >= 0) { transition.setDuration(duration); }// ww w . j ava2s.co m long startDelay = a.getInt(R.styleable.Transition_startDelay, -1); if (startDelay > 0) { transition.setStartDelay(startDelay); } final int resID = a.getResourceId(R.styleable.Transition_interpolator, 0); if (resID > 0) { transition.setInterpolator(AnimationUtils.loadInterpolator(mContext, resID)); } a.recycle(); return transition; }
From source file:ar.rulosoft.custompref.SeekBarCustomPreference.java
@Override protected Object onGetDefaultValue(TypedArray a, int index) { return a.getInt(index, 0); }
From source file:com.astuetz.viewpager.extensions.IndicatorLineView.java
public IndicatorLineView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0); mLineColor = a.getColor(R.styleable.ViewPagerExtensions_lineColor, mLineColor); mFadeOutTime = a.getInt(R.styleable.ViewPagerExtensions_fadeOutDelay, mFadeOutTime); mFadingDuration = a.getInt(R.styleable.ViewPagerExtensions_fadeOutDuration, mFadingDuration); a.recycle();/* ww w.j a v a 2 s .c om*/ }
From source file:com.chrismorais.android.sunshine.app.ForecastFragment.java
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.ForecastFragment, 0, 0); mChoiceMode = a.getInt(R.styleable.ForecastFragment_android_choiceMode, AbsListView.CHOICE_MODE_NONE); mAutoSelectView = a.getBoolean(R.styleable.ForecastFragment_autoSelectView, false); a.recycle();/*from w w w . jav a 2 s . c o m*/ }
From source file:com.astuetz.viewpager.extensions.ProgressLineView.java
public ProgressLineView(Context context, AttributeSet attrs, int defStyle) { super(context, attrs, defStyle); final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ViewPagerExtensions, defStyle, 0); mLineColor = a.getColor(R.styleable.ViewPagerExtensions_lineColor, mLineColor); mFadeOutTime = a.getInt(R.styleable.ViewPagerExtensions_fadeOutDelay, mFadeOutTime); mFadingDuration = a.getInt(R.styleable.ViewPagerExtensions_fadeOutDuration, mFadingDuration); a.recycle();/*from w w w. j a va 2 s.c om*/ }