title: ListView.setSelection is not working
body: <p>I am working on a dialog that has a <code>ListView</code> ..</p>
  
  <p>I have successfully put the adapter,selector,list_itemlayout in the <code>onCreate()</code> as follows..</p>
  
  <pre><code>protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
  
      setContentView(R.layout.variable_dialog);
  
      lv=(ListView) findViewById(R.id.VariableslistView1);
      lv.setAlwaysDrawnWithCacheEnabled(true);        
      final ArrayAdapter&lt;String&gt; ad=new ArrayAdapter&lt;String&gt;(getContext(),android.R.layout.simple_list_item_1,Program.get().symboltable.getSymbols());
      lv.setAdapter(ad);
  
      lv.setSelector(R.drawable.item_selected);
  </code></pre>
  
  <p>But whenever I try to get the <code>getSelectedItemPosition()</code> it alsways returns -1 </p>
  
  <p>as if I didn't select anything ..even if I invoke the selection my self like this:</p>
  
  <pre><code>lv.setSelected(true);
      lv.setSelection(1);
      lv.setItemChecked(1, true);
      ad.notifyDataSetChanged();
      ad.notifyDataSetInvalidated();
  </code></pre>
  
  <p>and here is my selector :</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;shape xmlns:android="http://schemas.android.com/apk/res/android" &gt;
   &lt;stroke
      android:width="2dp"
      android:color="#FF00FF00" /&gt;
  
  &lt;gradient
      android:angle="225"
      android:endColor="#DD2ECCFA"
      android:startColor="#DD000000" /&gt;
  
  &lt;corners
      android:bottomLeftRadius="7dp"
      android:bottomRightRadius="7dp"
      android:topLeftRadius="7dp"
      android:topRightRadius="7dp" /&gt;
  
  
  &lt;/shape&gt;
  </code></pre>
  
  <p>For god's sake what the heck is wrong?!?!</p>
  
  <p>I even tried the <code>AdapterView.OnItemSelectedListener</code> but never succeeded :|</p>
  
  <p>Can anybody tell me what is the problem .</p>
  
  <p>Thanks in advance</p>