在运行时更改xml文件中的值

时间:2017-01-10 18:58:09

标签: android xml sharedpreferences android-settings user-preferences

我有一项活动,用户可以更改应用的颜色重音。 选择的颜色保存在SharedPreferences内。

我希望能够通过应用colors.xml中保存的内容更改该内容,而不是在应用SharedPreferences文件中包含静态值。

<color name="colorAccent">#value_from_shared_preferences</color>

我知道还有其他不同的方法可以将用户指定的颜色用作应用强调颜色,但我想知道如何在应用colors.xml文件中切换出值。

更新:所有资源值都是常量,因此无法在运行时更改xml文件中的值。

参考: Programmatically change the value of a color resource obtained from API response

0 个答案:

没有答案