title: How to set the Default Value of a ListPreference
body: <p>i need to set the defult value for a ListPreference when the Activity starts.
  I've tried with <code>ListPreference.setDefaultvalue("value");</code> but it makes the firts Entry of the List as default. I need it because i must check a condition and set as default the value which satisfies that condition, so I think it can't be done from the xml file (with <code>android:defaultValue</code>)</p>
  
  <p>For example, suppose I have this array of values in the arrays.xml:</p>
  
  <pre><code>&lt;string-array name="opts"&gt;
      &lt;item&gt;red&lt;/item&gt;
      &lt;item&gt;green&lt;/item&gt;
      &lt;item&gt;blue&lt;/item&gt;
  &lt;/string-array&gt;
  
  &lt;string-array name="opts_values"&gt;
      &lt;item&gt;1&lt;/item&gt;
      &lt;item&gt;2&lt;/item&gt;
      &lt;item&gt;3&lt;/item&gt;
  &lt;/string-array&gt;
  </code></pre>
  
  <p>In the PreferenceScreen xml:</p>
  
  <pre><code>&lt;ListPreference
      android:title="Colour select"
      android:summary="Select your favourite"
      android:key="colour"
      android:entries="@array/opts"
      android:entryValues="@array/opts_values" /&gt;
  </code></pre>
  
  <p>In the Activity I'd like to do something like this:</p>
  
  <pre><code>String mycolour;
  if (something) {
      mycolour="1";
  } else {
      mycolour="2";
  }
  ListPreference colour = (ListPreference) findPreference ("colour");
  colour.setDefaultValue(mycolour);
  </code></pre>
  
  <p>But it doesn't work, because it makes the first choice as default. Could you explain me how to make another one as default? Thanks.</p>