Example usage for android.content Context obtainStyledAttributes

List of usage examples for android.content Context obtainStyledAttributes

Introduction

In this page you can find the example usage for android.content Context obtainStyledAttributes.

Prototype

public final TypedArray obtainStyledAttributes(AttributeSet set, @StyleableRes int[] attrs,
        @AttrRes int defStyleAttr, @StyleRes int defStyleRes) 

Source Link

Document

Retrieve styled attribute information in this Context's theme.

Usage

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

@Deprecated
public static Drawable getActionBarSplitBackground(final Context context, final boolean applyAlpha) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.backgroundSplit },
            android.R.attr.actionBarStyle, 0);
    final Drawable d = a.getDrawable(0);
    a.recycle();//from   ww w  . j a  va 2s .c o  m
    return applyActionBarDrawable(context, d, applyAlpha);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

@Deprecated
public static Drawable getActionBarStackedBackground(final Context context, final boolean applyAlpha) {
    final TypedArray a = context.obtainStyledAttributes(null, new int[] { android.R.attr.backgroundStacked },
            android.R.attr.actionBarStyle, 0);
    final Drawable d = a.getDrawable(0);
    a.recycle();//  w w  w.j  a  va 2  s.c o m
    return applyActionBarDrawable(context, d, applyAlpha);
}

From source file:au.com.lumo.ameego.uiUtils.MultiSwipeRefreshLayout.java

public MultiSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiSwipeRefreshLayout, 0, 0);

    mForegroundDrawable = a.getDrawable(R.styleable.MultiSwipeRefreshLayout_foreground);
    if (mForegroundDrawable != null) {
        mForegroundDrawable.setCallback(this);
        setWillNotDraw(false);//from  w w  w . j av a  2 s  . com
    }

    a.recycle();
}

From source file:cnc.cad.rxjavatestapp.meizi.rx.widget.MultiSwipeRefreshLayout.java

public MultiSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    final TypedArray array = context.obtainStyledAttributes(attrs, R.styleable.MultiSwipeRefreshLayout, 0, 0);

    mForegroundDrawable = array.getDrawable(R.styleable.MultiSwipeRefreshLayout_foreground);
    if (mForegroundDrawable != null) {
        mForegroundDrawable.setCallback(this);
        setWillNotDraw(false);//w w w  .j  a v  a 2 s.c  o m
    }
    array.recycle();
}

From source file:com.actionbarsherlock.internal.widget.CapitalizingTextView.java

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

    TypedArray a = context.obtainStyledAttributes(attrs, R_styleable_TextView, defStyle, 0);
    mAllCaps = a.getBoolean(R_styleable_TextView_textAllCaps, true);
    a.recycle();/*from   w  w  w  . j ava2  s  .co  m*/
}

From source file:com.aqtc.bmobnews.widget.MultiSwipeRefreshLayout.java

public MultiSwipeRefreshLayout(Context context, AttributeSet attrs) {
    super(context, attrs);
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.MultiSwipeRefreshLayout, 0, 0);

    this.mForegroundDrawable = a.getDrawable(R.styleable.MultiSwipeRefreshLayout_foreground);
    if (this.mForegroundDrawable != null) {
        this.mForegroundDrawable.setCallback(this);
        setWillNotDraw(false);//  ww  w .  jav  a 2  s  .  c  o m
    }

    a.recycle();
}

From source file:co.codecrunch.musicplayerlite.uicomponent.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;/*from w  w  w  .  j av a 2  s . c o m*/
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetForeground_ui);
    a.recycle();

    setWillNotDraw(true);
}

From source file:de.vanita5.twittnuker.util.ThemeUtils.java

public static int getThemeColor(Context context, int themeResourceId) {
    final Context appContext = context.getApplicationContext();
    final Resources res = appContext.getResources();
    final TypedArray a = appContext.obtainStyledAttributes(null,
            new int[] { android.R.attr.colorActivatedHighlight }, 0, themeResourceId);
    try {/*from   w w w.ja  va2s  .  com*/
        return a.getColor(0, res.getColor(R.color.material_light_blue));
    } finally {
        a.recycle();
    }
}

From source file:com.appdevper.mediaplayer.ui.ScrimInsetsRelativeLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;// ww w . j a  v  a 2s  .  c  o m
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_insetFore);
    a.recycle();

    setWillNotDraw(true);
}

From source file:ar.worq.microturistas.view.ScrimInsetsFrameLayout.java

private void init(Context context, AttributeSet attrs, int defStyle) {
    final TypedArray a = context.obtainStyledAttributes(attrs, R.styleable.ScrimInsetsView, defStyle, 0);
    if (a == null) {
        return;/*from  ww w . j a  v  a2 s. c o  m*/
    }
    mInsetForeground = a.getDrawable(R.styleable.ScrimInsetsView_scrimInsetForeground);
    a.recycle();
    setWillNotDraw(true);
}