2

This works lovely for doing it once statically.

But what if I have a font color preference, and I want the preference screen itself to update based on that?

Community
  • 1
  • 1
Vic Vuci
  • 6,993
  • 6
  • 55
  • 90

2 Answers2

2

Going with the information from this answer, you could try using a SpannableString object and set the color that way. The example from that answer:

Spannable summary = new SpannableString ("Currently This Color");
summary.setSpan( new ForgroundColorSpan(color), 0, summary.length(), 0 );
preference.setSummary(summary);
Community
  • 1
  • 1
Marvin Pinto
  • 30,138
  • 7
  • 37
  • 54
  • My mistake. This helps me a lot. My color is not a color int but a resource int, I didn't convert it at first, I should use `new ForegroundColorSpan(getResources().getColor(android.R.color.holo_red_dark))` – Owen Zhao Jul 10 '13 at 14:32
0

Have a look at my answer to this: Android PreferenceScreen title in two lines.

Add this:

if (textView != null) {
    textView.setTextColor(textView.getContext().getResources().getColor(R.color.blue));
}
Community
  • 1
  • 1
Codes12
  • 376
  • 6
  • 21