Skip to content Skip to sidebar Skip to footer

Android CheckBoxPreference Title Color

I am using the code in this answer. But instead of setting the android:textColor for the Text View i use style='?background_text_color_theme' which has to set the text color depe

Solution 1:

Here is how I did it..Just in case some one needs it in the future.

    public class CheckBoxPreferenceClass extends CheckBoxPreference {


    public CheckBoxPreferenceClass(Context context) {
        super(context);
    }

    public CheckBoxPreferenceClass(Context context, AttributeSet attrs) {
        super(context, attrs);
    }
    public CheckBoxPreferenceClass(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
    }

    @Override
    protected void onBindView(View view) {
        super.onBindView(view);
        TextView title = (TextView) view.findViewById(android.R.id.title);
        title.setTextColor(Color.BLACK);
    }

}

And in the preference xml use this for the checkbox preference:

  <packagename.CheckBoxPreferenceClass
        android:key="@string/imp"
        android:title="@string/title"/>

Post a Comment for "Android CheckBoxPreference Title Color"