get Text Color Primary - Android Graphics

Android examples for Graphics:Text Color

Description

get Text Color Primary

Demo Code


//package com.java2s;
import android.content.Context;
import android.content.res.ColorStateList;
import android.content.res.TypedArray;

public class Main {
    public static final int TEXT_COLOR_PRIMARY = android.R.attr.textColorPrimary;

    public static ColorStateList getTextColorPrimary(Context context) {
        return getSystemAttrColor(context, TEXT_COLOR_PRIMARY);
    }//www .  j  a  va 2s .co m

    public static ColorStateList getSystemAttrColor(Context context,
            int attr) {
        TypedArray a = context.obtainStyledAttributes(new int[] { attr });
        ColorStateList color = a.getColorStateList(a.getIndex(0));
        a.recycle();
        return color;
    }
}

Related Tutorials