List of usage examples for android.content.res TypedArray getResourceId
@AnyRes public int getResourceId(@StyleableRes int index, int defValue)
From source file:com.forrestguice.suntimeswidget.SuntimesUtils.java
public static ImageSpan createWarningSpan(Context context, int width, int height) { TypedArray a = context .obtainStyledAttributes(new int[] { R.attr.icActionWarning, R.attr.tagColor_warning }); int drawableID = a.getResourceId(0, DEF_WARNING_DRAWABLE); int colorID = a.getResourceId(1, R.color.warningTag_dark); a.recycle();/*w ww .j a v a 2s.co m*/ return createImageSpan(context, drawableID, width, height, ContextCompat.getColor(context, colorID)); }
From source file:com.emartynov.android.app.urlsetter.android.ui.fragment.PlaceholderFragment.java
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.PlaceholderFragment); fragmentLayout = a.getResourceId(R.styleable.PlaceholderFragment_fragment_layout, -1); a.recycle();//w ww . j a v a2 s . c om }
From source file:com.bilibili.magicasakura.widgets.TintCheckedTextView.java
public TintCheckedTextView(Context context, AttributeSet attrs, int defStyleAttr) { super(context, attrs, defStyleAttr); TypedArray array = context.obtainStyledAttributes(attrs, ATTRS); final int drawLeftId = array.getResourceId(0, 0); final int drawLeftTintId = array.getResourceId(1, 0); array.recycle();//w w w . ja v a2s .c om if (drawLeftId != 0 && drawLeftTintId != 0) { tintCheckTextView(drawLeftId, drawLeftTintId); } }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static int getActionBarPopupThemeRes(final Context context) { if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) return 0; final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.actionBarPopupTheme }); try {//from w ww . ja v a 2 s.co m return a.getResourceId(0, 0); } finally { a.recycle(); } }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static int getTextAppearanceLarge(final Context context) { // final Context wrapped = getThemedContext(context, // getResources(context)); final TypedArray a = context.obtainStyledAttributes(new int[] { android.R.attr.textAppearanceLarge }); final int textAppearance = a.getResourceId(0, android.R.style.TextAppearance_Holo_Large); a.recycle();//from ww w .jav a 2 s.c o m return textAppearance; }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static void overrideActivityCloseAnimation(final Activity activity) { TypedArray a = activity.obtainStyledAttributes(new int[] { android.R.attr.windowAnimationStyle }); final int windowAnimationStyleResId = a.getResourceId(0, 0); a.recycle();/*from ww w .j av a2 s . com*/ // Now retrieve the resource ids of the actual animations used in the // animation style pointed to by // the window animation resource id. a = activity.obtainStyledAttributes(windowAnimationStyleResId, ANIM_CLOSE_STYLE_ATTRS); final int activityCloseEnterAnimation = a.getResourceId(0, 0); final int activityCloseExitAnimation = a.getResourceId(1, 0); a.recycle(); activity.overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation); }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static void overrideActivityOpenAnimation(final Activity activity) { TypedArray a = activity.obtainStyledAttributes(new int[] { android.R.attr.windowAnimationStyle }); final int windowAnimationStyleResId = a.getResourceId(0, 0); a.recycle();//from w ww . java2 s.c o m // Now retrieve the resource ids of the actual animations used in the // animation style pointed to by // the window animation resource id. a = activity.obtainStyledAttributes(windowAnimationStyleResId, ANIM_OPEN_STYLE_ATTRS); final int activityOpenEnterAnimation = a.getResourceId(0, 0); final int activityOpenExitAnimation = a.getResourceId(1, 0); a.recycle(); activity.overridePendingTransition(activityOpenEnterAnimation, activityOpenExitAnimation); }
From source file:com.emartynov.android.app.urlsetter.android.ui.fragment.UrlListFragment.java
@Override public void onInflate(Activity activity, AttributeSet attrs, Bundle savedInstanceState) { super.onInflate(activity, attrs, savedInstanceState); TypedArray a = activity.obtainStyledAttributes(attrs, R.styleable.PlaceholderFragment); int keys = a.getResourceId(R.styleable.PlaceholderFragment_list_fragment_keys, -1); if (keys != -1) { keyIds = keys;//w w w . ja v a 2 s . co m } int values = a.getResourceId(R.styleable.PlaceholderFragment_list_fragment_values, -1); if (values != -1) { valuesIds = values; } a.recycle(); }
From source file:arun.com.chromer.settings.widgets.ColorPreference.java
private void init(Context context, AttributeSet attrs) { setWidgetLayoutResource(R.layout.widget_color_preference); DEFAULT_COLOR = ContextCompat.getColor(getContext(), R.color.colorPrimary); if (attrs != null) { TypedArray ta = context.obtainStyledAttributes(attrs, R.styleable.ColorPreference); int colorRes = ta.getResourceId(R.styleable.ColorPreference_color, 0); if (colorRes != 0) { color = ContextCompat.getColor(getContext(), colorRes); }/*from ww w . j a v a2s. c o m*/ ta.recycle(); } }
From source file:de.vanita5.twittnuker.util.ThemeUtils.java
public static void overrideNormalActivityCloseAnimation(final Activity activity) { final TypedArray a = activity.obtainStyledAttributes(null, ANIM_CLOSE_STYLE_ATTRS, 0, android.R.style.Animation_Activity); final int activityCloseEnterAnimation = a.getResourceId(0, 0); final int activityCloseExitAnimation = a.getResourceId(1, 0); a.recycle();//from w w w . j a v a2s . co m activity.overridePendingTransition(activityCloseEnterAnimation, activityCloseExitAnimation); }