How-to init a ListPreference to one of its values

You need to specify the value. So to get the first entry selected by default specify defaultValue="300" in your example.


Happened to be in same situation. Specifying a consistent default value. But graphically was not selected. I cleared the application data. And then it worked as expected. So a clear may be useful at dev time when adding new XxxPreference items.


In addition to Sven's answer, you have to call the setDefaultValues() method in the starting activity. This will set once all default values.

public class MainActivity extends Activity {
  protected void onCreate(final Bundle savedInstanceState) {
  // Set all default values once for this application
  // This must be done in the 'Main' first activity
  PreferenceManager.setDefaultValues(this, R.xml.preferences, false);
  ...
  }
}