0

Here i have my preferences in xml folder. No matter what I set as "defaultValue" I always get visually unchecked box, when I open my preference activity. Is this some kind of bug?

<PreferenceScreen xmlns:android="http://schemas.android.com/apk/res/android" >

  <CheckBoxPreference 
     android:title="Enabled" 
     android:defaultValue="true" 
     android:key="checkbox_enabled_disabled"/>   

</PreferenceScreen>
Trinimon
  • 13,839
  • 9
  • 44
  • 60
rootpanthera
  • 2,731
  • 10
  • 33
  • 65

2 Answers2

0

Inside You PreferenceActivity subclass you can fire following code.

checkboxPref=(CheckBoxPreference)findPreference("myPreference");
checkboxPref.setChecked(true);

This is just one of the approach.basically you will have to handle logic to not execute this code when user manually unchecked the preference.

Vipul
  • 27,808
  • 7
  • 60
  • 75
0

actually, this bug was already fixed. I'm just being an idiot (or eclipse)

The thing is that when i installed application on emulator it really loaded default value. (The one that i defined in XML ) Then i changed it (in emulator). So then i put some more code in program and then i ran it again, but the thing is that previous value that i changed was still stored in emulator, even if i updated and i ran application from eclipse. That's why i was always getting up with false value (i left it false in program).

rootpanthera
  • 2,731
  • 10
  • 33
  • 65