android - How to change Preference text colour programmatically? -


i'm adding preferences programmatically instance of preferencescreen (which add preferenceactivity). works expected except text colour, white despite trying:

  • to set theme through manifest
  • set theme programmatically
  • a few other hacks aren't notable

all i'm doing:

    preferencescreen screen = getpreferencemanager().createpreferencescreen(this);      preferencecategory category = new preferencecategory(this);     category.settitle("hello");      screen.addpreference(category);      checkboxpreference testpreference = new checkboxpreference(getapplicationcontext());     testpreference.settitle("test");     category.addpreference(testpreference);      setpreferencescreen(screen); 

i've set theme themeoverlay.appcompat.dark (which don't want) , text legible, looks in other case (i'm tapping can see text through animation effect): enter image description here

how go making text black?

thanks!

simple fix, actually:

i had called getapplicationcontext() in checkboxpreference testpreference = new checkboxpreference(getapplicationcontext()); not recommended inflating views pass wrong theme.

so, changed getapplicationcontext() this , loaded text colour described in theme.


Comments

Popular posts from this blog

yii2 - Yii 2 Running a Cron in the basic template -

asp.net - 'System.Web.HttpContext' does not contain a definition for 'GetOwinContext' Mystery -

mercurial graft feature, can it copy? -