title: Android - change image of ImageButton when pressed and release
body: <p>I would like to set image1 for the button, but when it is pressed - change it to image2. After releasing, the button should be again an image1. I tried to do it this way in onClick() method:</p>
  
  <pre><code>  button.setImageResource(R.drawable.image1);
         if(button.isPressed())
              button.setImageResource(R.drawable.image2);
  </code></pre>
  
  <p>but after first pressing the image of button changed to the image2 and stayed like that.<br>
  Could You help me with that problem? </p>