title: Android programatically setting a ListView row to activated
body: <p>I'm using the following selector to change set a row's background when it is selected</p>
  
  <pre><code>&lt;item android:state_activated="true" android:drawable="@drawable/row_sel" /&gt;
  &lt;item android:drawable="@drawable/row_neut"/&gt;   
  </code></pre>
  
  <p>It works fine when a row is phyiscally clicked. All I want to do is programatically set a row to be selected. I thought this would be trivial, but after over an hour of trying and googling, I can't find an answer. </p>
  
  <p>Things I've tried:</p>
  
  <ul>
  <li><code>listView.setSelection(0)</code></li>
  <li><code>listView.setItemChecked(0)</code></li>
  <li><code>listView.getItem(0).setActivated(true) //fails: getChildCount() is 0</code></li>
  <li><code>adapter.notifyDataSetChanged()</code>, <code>listView.invalidate() //out of desperation</code></li>
  </ul>
  
  <p>I could obviously use a hack within the adapter (i.e assign selected/neutral Drawable each time) but I'd rather have it clean.</p>