title: Android button states programmatically in Java (not XML)
body: <p>How does one define Android button image for the "state_pressed" 
  "android:state_focused" in Java? </p>
  
  <p>For example, how would one accomplish the equivalent in Java for the XML from</p>
  
  <p><a href="http://developer.android.com/reference/android/widget/ImageButton.html">http://developer.android.com/reference/android/widget/ImageButton.html</a></p>
  
  <pre><code> &lt;?xml version="1.0" encoding="utf-8"?&gt;
   &lt;selector xmlns:android="http://schemas.android.com/apk/res/android"&gt;
       &lt;item android:state_pressed="true"
             android:drawable="@drawable/button_pressed" /&gt; &lt;!-- pressed --&gt;
       &lt;item android:state_focused="true"
             android:drawable="@drawable/button_focused" /&gt; &lt;!-- focused --&gt;
       &lt;item android:drawable="@drawable/button_normal" /&gt; &lt;!-- default --&gt;
   &lt;/selector&gt;
  </code></pre>