TypedArray getColor - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for TypedArray getColor method.

This code example shows how to use the following methods:getColor
        int[] attrs = new int[]{attr};
        Context context = GlobalContext.getInstance().getActivity();
//        if (context == null) 
//            context = GlobalContext.getInstance(); 
        TypedArray ta = context.obtainStyledAttributes(attrs);
        return ta.getColor(0, 430);
 
    } 
 
    //can't find a public theme attr to modify actionbar searchview text color 
    public static void customActionBarSearchViewTextColor(SearchView searchView) {
        int id = searchView.getContext().getResources().getIdentifier("android:id/search_src_text", null, null);
        TextView textView = (TextView) searchView.findViewById(id);
        textView.setTextColor(Color.WHITE);
 
    } 
 
} 
6
CodeRank
This code example shows how to use the following methods:getColor, recycle
 
	public int getColor(String attrName, int defaultValue) {
		int[] attr = ThemeUtils.getAttributeIds(mContext,
				new String[] { attrName }, mPackageName);
		TypedArray a = mContext.obtainStyledAttributes(mThemeId, attr);
		int c = a.getColor(0, defaultValue);
		a.recycle();
		return c;
	} 
 
	public int getDimensionPixelOffset(String attrName, int defaultValue) {
		int[] attr = ThemeUtils.getAttributeIds(mContext,
				new String[] { attrName }, mPackageName);
		TypedArray a = mContext.obtainStyledAttributes(mThemeId, attr);
		int i = a.getDimensionPixelOffset(0, defaultValue);
		a.recycle();
		return i;
	} 
 
	public int getInteger(String attrName, int defaultValue) {
6
CodeRank
This code example shows how to use the following methods:getColor
		init(context, attrs);
	} 
 
	@Override 
	protected Object onGetDefaultValue(TypedArray a, int index) {
		return a.getColor(index, Color.BLACK);
	} 
 
	@Override 
	protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
		onColorChanged(restoreValue ? getPersistedInt(mValue) : (Integer) defaultValue);
	} 
 
	private void init(Context context, AttributeSet attrs) {
		mDensity = getContext().getResources().getDisplayMetrics().density;
		setOnPreferenceClickListener(this);
	} 
 
	@Override 
	protected void onBindView(View view) {
4
CodeRank
This code example shows how to use the following methods:getColor, recycle
 
        /* get attribute array */ 
        TypedArray ta = context.obtainStyledAttributes(parser, sStyleable.resolveIntArray("Stage"));
 
        /* set StageBgColor */ 
        int stageBgColor = ta.getColor(sStyleable.resolveInt("Stage_backgroundColor"), -1);
        log(TAG, "Stage stageBgColor : " + stageBgColor);
        if (stageBgColor != -1) {
            stage.setBackgroundColor(new Color(stageBgColor));
        } 
 
        ta.recycle();
        return stage;
    } 
 
    /** 
     * parse attribute of text in the xml parser 
     * 
     * @param context : the application environment 
     * @param parser: the xml resource parser created from the xml file 
4
CodeRank

Related TypedArray getColor Questions & Answers:

getColor Method Overview
Retrieve the color value for the attribute at index.
See Code Examples for other Android TypedArray Methods: