Skip to content Skip to sidebar Skip to footer

How To Change Title Text-color In Preference Category

Solution 1:

Create a class which extends PreferenceCategory.

publicclassCustomPreferenceCategoryextendsPreferenceCategory {

@TargetApi(21)publicCustomPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr, int defStyleRes) {
    super(context, attrs, defStyleAttr, defStyleRes);
    this.init(context, attrs);
}

publicCustomPreferenceCategory(Context context, AttributeSet attrs, int defStyleAttr) {
    super(context, attrs, defStyleAttr);
    this.init(context, attrs);
}

publicCustomPreferenceCategory(Context context, AttributeSet attrs) {
    super(context, attrs);
    this.init(context, attrs);
}

publicCustomPreferenceCategory(Context context) {
    super(context);
    this.init(context, (AttributeSet)null);
}

publicvoidonBindViewHolder(PreferenceViewHolder holder) {
    super.onBindViewHolder(holder);
    TextViewtitle= (TextView)holder.itemView;
    title.setTextColor(Color.BLACK);
}
privatevoidinit(Context context, AttributeSet attrs) {
    this.setLayoutResource(R.layout.preference_category);
}

Then replace PreferenceCategory with name of custom class in xml like this:

<mypackage.CustomPreferenceCategoryandroid:title="Login email">

Post a Comment for "How To Change Title Text-color In Preference Category"