title: Usage of gif in ImageButton
body: <p>How to toggle between an animated GIF image and a static one in ImageButton's src when someone clicks it?</p>
  
  <p>in <code>onCreate()</code> I have this</p>
  
  <pre><code>aButton3 = (ImageButton) findViewById(R.id.imageButton3);
  SharedPreferences sharedPreferences = getSharedPreferences("NAME", Context.MODE_PRIVATE);
  Boolean e = sharedPreferences.getBoolean("clicked3", false);
  </code></pre>
  
  <p>The following gets executed when someone clicks the ImageButton</p>
  
  <pre><code>public void buttonClick2(View v) {
      SharedPreferences sharedPreferences = getSharedPreferences("NAME", Context.MODE_PRIVATE);
      Boolean d = sharedPreferences.getBoolean("clicked2", false);
      if (!d) {
          toggleSound.start();
          aButton2.setImageResource(R.drawable.on);
          sharedPreferences = getSharedPreferences("NAME", Context.MODE_PRIVATE);
          SharedPreferences.Editor editor = sharedPreferences.edit();
          editor.putBoolean("clicked2", true);
          editor.commit();
      }
      if(d){
          toggleSound.start();
          aButton2.setImageResource(R.drawable.off);
          sharedPreferences = getSharedPreferences("NAME", Context.MODE_PRIVATE);
          SharedPreferences.Editor editor = sharedPreferences.edit();
          editor = sharedPreferences.edit();
          editor.putBoolean("clicked2", false);
          editor.commit();
      }
  }
  </code></pre>