title: Change image button on hold
body: <p>I want to change image of an Image Button on hold and change it back on release.
  Here is my primary code help to edit this.
  xml codes:</p>
  
  <pre><code>&lt;ImageButton
                  android:layout_width="62dp"
                  android:layout_weight="1"
                  android:layout_height="60dp"
                  android:id="@+id/im1"
                  android:layout_gravity="fill_horizontal"
                  android:src="@drawable/off1"/&gt;
  </code></pre>
  
  <p>and java codes:</p>
  
  <pre><code>im1 = (ImageButton) findViewById(R.id.im1);
          im1.setOnClickListener(new OnClickListener() {
              public void onClick(View v) {
            //some codes
            }
          });
  </code></pre>