title: Android eclipse add pressed state to ImageView
body: <p>Is there a way to add a pressed state to an ImageView?  I have an image that i place a click listener on, and when I press it I want to change to imageview src for a second to mimic the pressed state of buttons or listview items.</p>
  
  <p>Can I add a selector xml to the src attribute?</p>
  
  <p>Figured it out.  You CAN add a selector xml to your src attribute of an ImageView.
  In my case, i created "addbuttonbg.xml" in my drawables:</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_selected="false"
      android:state_pressed="false" 
      android:drawable="@drawable/quickaddbutton" /&gt;
  &lt;item android:state_pressed="true" 
      android:drawable="@drawable/quickaddbutton_click" /&gt;
  &lt;item android:state_selected="true"
   android:state_pressed="false" 
      android:drawable="@drawable/quickaddbutton" /&gt;
  &lt;/selector&gt;
  </code></pre>
  
  <p>Then set your imageview src to @drawable/addbuttonbg</p>