title: Android - make ImageView "blink"
body: <p>I want to make my ImageView appear to blink. More exactly, on an event like a button click, I want an ImageView to change its src for 1 second, then change back, then again etc. And then it should stop, and the ImageView should have the same src as previous.
  I tried to do something based on another question, but it doesn't work...</p>
  
  <pre><code>private class MyHandler extends Handler {
      public ImageView imgView;
  
      @Override
      public void handleMessage(Message msg) {
          if (imgView != null) {
              switch (msg.what) {
              case 0:
                  imgView.setImageResource(R.drawable.red_img);
                  break;
              case 1:
                  imgView.setImageResource(R.drawable.white_img);
                  break;
  
              }
          }
          super.handleMessage(msg);
      }
  }
  
  (...)
  
  MyHandler blinker = new MyHandler();
  blinker.imgView = imgView;
  for (int j = 0; j &lt; 5; j++) {
      Message msg = new Message();
      if (j % 2 == 0) {
          msg.what = 0;
      } else {
          msg.what = 1;
      }
  
      blinker.sendMessageDelayed(msg, j * 300);
  }
  </code></pre>
  
  <p>Does anyone know how this can be done (if it CAN be done).
  Thanks!</p>