1

I am using holoeverywhere. I have created my own theme for my app and I can apply this theme to my activities with success. My theme changes drawables for CheckBox, EditText, DatePicker and so on. The problem is that this theme does npot work for PreferenceActivity. What I find puzzling is if I set the theme to Holo.Theme or Holo.Theme.Light it changes as it should. But if I change it to my theme which is derived from Holo.Theme.Light it does not. Yet, an all other activities it does work. I change activity theme via:

activity.setTheme(R.style.MyCustomTheme);

All this works for all other activities just not for PreferenceActivity. Are there some undocumented atributes which must be set to change preference activity theme?

2 Answers2

3

styles.xml

<style name="SettingsTheme" parent="android:Theme.Light">
   <!-- Override properties according to your need -->
   <item name="android:colorBackground">#ffffff</item>
   <item name="android:colorForeground">#aaaaaa</item>

   <item name="android:textColorPrimary">#ff0000</item>
   <item name="android:textColorSecondary">#0000ff</item>
   <item name="android:textColorTertiary">#00ff00</item>
   <item name="android:textColorPrimaryDisableOnly">#888888</item>
   <item name="android:textColorHint">#778899</item>
</style>

Apply your newly defined style to Preference Activity in AndroidManifest.xml using android:theme

<activity android:name=".SettingsThemeActivity"
      android:label="@string/app_name"
      android:theme="@style/SettingsTheme">

Edit: Try to set the the theme before

setTheme(R.style.SettingsTheme);

setContentView(R.layout.main);
Zohra Khan
  • 5,182
  • 4
  • 25
  • 34
  • This has absolutely nothing nothing to do with my problem. Please read the question again. Or perhaps if I refraze in simple form: how to set a diferent drawable for prefrence CheckBox? –  May 04 '14 at 15:42
  • No. I set the theme via code because a user can choose a theme. As I said my teheme with all the drawables and such works for all other activities. Preference activity is somehow different. I suspect there are some undocumented attributes in theme to set a style for preference activity. –  May 04 '14 at 15:47
  • Try to override onApplyThemeResource – Zohra Khan May 04 '14 at 16:05
0

No, it's not undocumented: "I put custom preference styles in the activity theme, but nothing happened!".

For preference items/views using other themes (not the activity theme), you should remap the theme with the PreferenceInit.map method.

import org.holoeverywhere.app.Application;

public class MyApplication extends Application {
  static {
    PreferenceInit.map(R.style.CustomPreferenceTheme, R.style.CustomPreferenceTheme_Light);
  }
}
Brais Gabin
  • 5,827
  • 6
  • 57
  • 92
  • Ok. so one has to add this code to the application. Hwat is CustompreferenceTheme and what is CustomPreferenceThem_light.? Where does my existing custom application theme come into play? –  May 06 '14 at 07:39
  • So this was just copy paste from first google hit and nothing else? –  May 07 '14 at 06:42
  • No, it's not, I link the source ;) and I copy only the esencial. For further information use the source. Answer only with a link it's bad practice. Answer with a link and a quote of what this link said it isn't a bad practice. – Brais Gabin May 07 '14 at 06:48
  • This is not a solution. Checked and double checked. –  May 07 '14 at 06:58