So here is the situation:
- I have
DogActivity
andFavoritesActivity
.DogActivity
is just aListView
. When you click on aDog
in the list, it takes you toFavoritesActivity
. - I want to have a number of themes ready to go. They don’t need to be dynamically generated. They can already exist in XML form.
- Depending on which dog the user selects from the list, I want to have the
FavoritesActivity
shown in one of my pre-existing themes.
I hear talks about ContextWrapper
, but I am not sure how to apply it. Any thoughts on how I may accomplish this?
Details:
Here is the usual single theme:
for v21/styles.xml
<resources>
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="android:colorControlHighlight">@color/colorAccentLight</item>
<item name="android:colorControlNormal">@color/colorAccent</item>
<item name="android:itemTextAppearance">@style/AppTheme.itemTextStyle</item>
<item name="popupMenuStyle">@style/PopupMenu.MyAppTheme</item>
</style>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="android:colorControlHighlight">@color/colorAccentLight</item>
</style>
<style name="AppTheme.itemTextStyle" parent="@android:style/TextAppearance.Widget.IconMenu.Item">
<item name="android:textColor">@color/colorPrimary</item>
</style>
</resources>
for styles.xml
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
Want I want to do:
Essentially I just want to change the colorPrimary
, colorPrimaryDark
and colorAccent
on the fly and have all the styles and themes and XML layouts that use them to change. So if I can change those colors before I launch FavoritesActivity
then that would solve my problems.