Reputation: 123
What is the best method to set a widget colors theme saved on SharedPreferences. Users choose their preferred colors theme and programatically I set the theme.
For example I have two styles for a TextView with id "widgetThemeDate":
<style name="widgetThemeDate" parent="@style/widgetThemeLight">
<item name="android:textColor">@color/colorWhite</item>
</style>
<style name="widgetThemeDate" parent="@style/widgetThemeDark">
<item name="android:textColor">@color/colorBlack</item>
</style>
In this case I receive the following error: "error: Resource entry widgetThemeDate already has bag item android:textColor."
How can I set "widgetThemeDate" color depending user's choice?
Upvotes: 2
Views: 2898
Reputation: 30825
You can't set whole themes on a view programatically (see this discussion), but you can change certain aspects progamatically. For instance. you case you could use the setTextColor() method to change the color of text programatically on ay TextView.
Upvotes: 1