title: Change an imageview when it is clicked
body: <p>I want the imageview with the Id = soundtoggle to switch to R.drawable.sound_on under the if condition and otherwise to R.drawable.sound_off. But i am not able to do it. Please help</p>
  
  <pre><code>    package com.twodwarfs.fallanimation;
  
      import com.tmp.animation.R;
  
      import android.os.Bundle;
      import android.app.Activity;
      import android.view.View;
      import android.view.View.OnClickListener;
      import android.widget.Button;
      import android.widget.ImageView;
  
      public class ToggleActivity extends Activity 
      { 
           protected void onCreate(Bundle savedInstanceState) 
           {
                  super.onCreate(savedInstanceState);
          setContentView(R.layout.homescreen);
          final ImageView img1 = (ImageView) findViewById(R.id.soundtoggle);
          img1.setOnClickListener(new OnClickListener() {
  
              @Override
              public void onClick(View v)
              {
                  if(v.getId() == R.id.soundtoggle)
                  {
                      img1.setBackground(getResources().getDrawable(R.drawable.sound_on));
                  }
                  else 
                  {
                      img1.setBackground(getResources().getDrawable(R.drawable.sound_off));
                  }
              }});
          }
       }
  
  &lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:orientation="vertical" android:background="@drawable/home_screen"&gt;
  
  &lt;ImageView
      android:id="@+id/musictoggle"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/soundtoggle"
      android:layout_centerHorizontal="true"
      android:src="@drawable/music_off"
      android:layout_marginLeft="5dp"
      android:clickable="true" /&gt;
  &lt;ImageView
      android:id="@+id/soundtoggle"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/musictoggle"
      android:layout_below="@+id/playbutton"
      android:src="@drawable/sound_off" 
      android:layout_marginLeft="1dp" 
      /&gt;
  &lt;Button
      android:id="@+id/playbutton"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignLeft="@+id/soundtoggle"
      android:layout_alignParentTop="true"
      android:layout_marginTop="178dp"
      android:background="@drawable/play"
      android:layout_marginLeft="1dp" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>my full xml which consists of 3 buttons play,sound and music</p>