/** * @param context The {@link Context} to use * @param attrs The attributes of the XML tag that is inflating the view. */ public ThemeableTextView(final Context context, final AttributeSet attrs) { super(context, attrs); // Initialze the theme resources final ThemeUtils resources = new ThemeUtils(context); // Retrieve styles attributes final TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.ThemeableTextView, 0, 0); // Get the theme resource name final String resourceName = typedArray.getString(R.styleable.ThemeableTextView_themeResource); // Theme the text color if (!TextUtils.isEmpty(resourceName)) { setTextColor(resources.getColor(resourceName)); } // Recyle the attrs typedArray.recycle(); }