Android Resources.Theme - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Android Resources.Theme class.

This code example shows how to use the following methods:resolveAttribute
This code example shows how to use the following methods:resolveAttribute
 
    protected Drawable getActionBarBackground(Context context) {
        int[] android_styleable_ActionBar = {android.R.attr.background};
 
        // Need to get resource id of style pointed to from actionBarStyle 
        TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true);
        // Now get action bar style values... 
        TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId,
                android_styleable_ActionBar);
        try { 
            // background is the first attr in the array above so it's index is 0. 
            return abStyle.getDrawable(0);
        } finally { 
            abStyle.recycle();
        } 
    } 
 
    protected int getActionBarSize(Context context) {
        int[] attrs = {android.R.attr.actionBarSize};
7
CodeRank
This code example shows how to use the following methods:resolveAttribute
This code example shows how to use the following methods:resolveAttribute
		} 
		return ret;
	} 
 
	public static int getEditTextColor(Context ctx) {
		TypedValue tv = new TypedValue();
		boolean found = ctx.getTheme().resolveAttribute(android.R.attr.editTextColor, tv, true);
		if (found) {
			// SDK 11+ 
			return ctx.getResources().getColor(tv.resourceId);
		} else { 
			// SDK < 11 
			return ctx.getResources().getColor(android.R.color.primary_text_light);
		} 
	} 
} 
7
CodeRank
This code example shows how to use the following methods:resolveAttribute
			Util.bug(null, ex);
		} 
	} 
 
	private static int getThemed(int attr, Context context) {
		TypedValue typedvalueattr = new TypedValue();
		context.getTheme().resolveAttribute(attr, typedvalueattr, true);
		return typedvalueattr.resourceId;
	} 
} 
6
CodeRank
This code example shows how to use the following methods:resolveAttribute
 
	protected int getActionBarTitleStyle(final Context context) {
		final int[] android_styleable_ActionBar = { android.R.attr.titleTextStyle };
 
		// Need to get resource id of style pointed to from actionBarStyle 
		final TypedValue outValue = new TypedValue();
		context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true);
		// Now get action bar style values... 
		final TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId,
				android_styleable_ActionBar);
		try { 
			// titleTextStyle is the first attr in the array above so it's index 
			// is 0. 
			return abStyle.getResourceId(0, 0);
		} finally { 
			abStyle.recycle();
		} 
	} 
 
	protected int getMinimumApiLevel() { 
7
CodeRank
This code example shows how to use the following methods:resolveAttribute
    /** 
     * Resolves the given attribute id of the theme to a resource id 
     */ 
    public static int getAttribute(Theme theme, int attrId) {
        final TypedValue outValue = new TypedValue();
        theme.resolveAttribute(attrId, outValue, true);
        return outValue.resourceId;
    } 
 
    /** 
     * Returns the resource id of the background used for buttons to show pressed and focused state 
     */ 
    public static int getSelectableItemBackground(Theme theme) {
        return getAttribute(theme, android.R.attr.selectableItemBackground);
    } 
 
    /** 
     * Returns the resource id of the background used for list items that show activated background 
     */ 
    public static int getActivatedBackground(Theme theme) {
6
CodeRank
This code example shows how to use the following methods:resolveAttribute
 
    protected Drawable getActionBarBackground(Context context) {
        int[] android_styleable_ActionBar = { android.R.attr.background };
 
        // Need to get resource id of style pointed to from actionBarStyle 
        TypedValue outValue = new TypedValue();
        context.getTheme().resolveAttribute(android.R.attr.actionBarStyle, outValue, true);
        // Now get action bar style values... 
        TypedArray abStyle = context.getTheme().obtainStyledAttributes(outValue.resourceId,
                android_styleable_ActionBar);
        try { 
            // background is the first attr in the array above so it's index is 0. 
            return abStyle.getDrawable(0);
        } finally { 
            abStyle.recycle();
        } 
    } 
 
    protected int getActionBarSize(Context context) {
        int[] attrs = { android.R.attr.actionBarSize };
6
CodeRank
This code example shows how to use the following methods:resolveAttribute
This code example shows how to use the following methods:resolveAttribute
    private int mAnimations;
    private MenuBuilder mMenu;
 
    public ExpandedMenuView(Context context, AttributeSet attrs) {
        super(context, attrs);
        TypedValue value = new TypedValue();
        context.getTheme().resolveAttribute(
                android.R.attr.windowAnimationStyle, value, true);
        mAnimations = value.resourceId;
        setOnItemClickListener(this);
    } 
 
    @Override 
    public int getWindowAnimations() { 
        return mAnimations;
    } 
 
    @Override 
    public void initialize(MenuBuilder menu) {
        mMenu = menu;
6
CodeRank

Related Android Resources.Theme Questions & Answers:

See Code Examples for Android Resources.Theme Methods: