title: Android : How to get the src of an imageButton
body: <p>I have an ImageButton and when I click on it I would like to change the image, but only if this is a special image (the default one in fact).</p>
  
  <p>My xml :</p>
  
  <pre><code>&lt;ImageButton
  android:id="@+id/button1"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:contentDescription="@string/button1"
  android:src="@drawable/imgdefault" /&gt;
  </code></pre>
  
  <p>And I have a listener on it :</p>
  
  <pre><code>public OnClickListener button1Listener = new OnClickListener() {
  
       @Override
       public void onClick(View v) {
            if (button1.getDrawable().equals(getResources().getDrawable(R.drawable.imgdefault))) {
                 button1.setImageResource(R.drawable.newImg);
      }
  }
  </code></pre>
  
  <p>But it seems that my "if" is never true. So I can I check if this is still my default image on the ImageButton ?</p>
  
  <p>Thank you for your help.</p>