title: Why setImageResource method is not working?
body: <p>This is the first canvas:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;
  &lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
                  android:layout_width=&quot;fill_parent&quot;
                  android:layout_height=&quot;fill_parent&quot;
                  android:orientation=&quot;vertical&quot;
                  android:background=&quot;@drawable/background_linen&quot; &gt;
  
    &lt;ScrollView
            android:id=&quot;@+id/scrollView1&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot; &gt;
  
      &lt;TableLayout
              android:layout_width=&quot;fill_parent&quot;
              android:layout_height=&quot;wrap_content&quot; &gt;
  
        &lt;TableRow
                android:id=&quot;@+id/TableRow01&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;TextView
                  android:id=&quot;@+id/TextView03&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot; &quot;
                  android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;
        &lt;/TableRow&gt;
  
        &lt;TableRow
                android:id=&quot;@+id/tableRow1&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;ImageView
                  android:id=&quot;@+id/img1&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;150dp&quot;
                  android:src=&quot;@drawable/girbaud1front&quot; /&gt;
  
        &lt;/TableRow&gt;
  
        &lt;TableRow
                android:id=&quot;@+id/tableRow2&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;TextView
                  android:id=&quot;@+id/TextView01&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot; &quot;
                  android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;
        &lt;/TableRow&gt;
  
        &lt;TableRow
                android:id=&quot;@+id/tableRow3&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;ImageView
                  android:id=&quot;@+id/img2&quot;
                  android:layout_width=&quot;320dp&quot;
                  android:layout_height=&quot;150dp&quot;
                  android:src=&quot;@drawable/girbaud4front&quot; /&gt;
  
        &lt;/TableRow&gt;
  
        &lt;TableRow
                android:id=&quot;@+id/tableRow4&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;TextView
                  android:id=&quot;@+id/textView1&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot; &quot;
                  android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;
        &lt;/TableRow&gt;
  
        &lt;TableRow
                android:id=&quot;@+id/tableRow5&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;ImageView
                  android:id=&quot;@+id/img3&quot;
                  android:layout_width=&quot;320dp&quot;
                  android:layout_height=&quot;150dp&quot;
                  android:src=&quot;@drawable/girbaud2front&quot; /&gt;
  
        &lt;/TableRow&gt;
  
        &lt;TableRow
                android:id=&quot;@+id/TableRow6&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;TextView
                  android:id=&quot;@+id/TextView02&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot; &quot;
                  android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;
        &lt;/TableRow&gt;
  
        &lt;TableRow
                android:id=&quot;@+id/TableRow7&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;ImageView
                  android:id=&quot;@+id/img4&quot;
                  android:layout_width=&quot;320dp&quot;
                  android:layout_height=&quot;150dp&quot;
                  android:src=&quot;@drawable/girbaud3front&quot; /&gt;
  
        &lt;/TableRow&gt;
  
        &lt;TableRow
                android:id=&quot;@+id/TableRow02&quot;
                android:layout_width=&quot;wrap_content&quot;
                android:layout_height=&quot;wrap_content&quot; &gt;
  
          &lt;TextView
                  android:id=&quot;@+id/TextView04&quot;
                  android:layout_width=&quot;wrap_content&quot;
                  android:layout_height=&quot;wrap_content&quot;
                  android:text=&quot; &quot;
                  android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot; /&gt;
        &lt;/TableRow&gt;
  
      &lt;/TableLayout&gt;
    &lt;/ScrollView&gt;
  
  &lt;/RelativeLayout&gt; 
  </code></pre>
  <p>The second canvas that image change will happen is this file:</p>
  <pre class="lang-xml prettyprint-override"><code>&lt;RelativeLayout xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
                  android:id=&quot;@+id/Layout01&quot;
                  android:layout_width=&quot;fill_parent&quot;
                  android:layout_height=&quot;fill_parent&quot; &gt;
  
    &lt;ImageView
            android:id=&quot;@+id/ImageView01&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_alignParentBottom=&quot;true&quot;
            android:layout_alignParentLeft=&quot;true&quot;
            android:layout_alignParentRight=&quot;true&quot;
            android:layout_alignParentTop=&quot;true&quot;
            android:layout_marginBottom=&quot;10dp&quot;
            android:layout_marginTop=&quot;10dp&quot;
            android:layout_marginRight=&quot;10dp&quot;
            android:layout_marginLeft=&quot;10dp&quot;
            android:scaleType=&quot;fitXY&quot;
            android:src=&quot;@drawable/girbaud1front&quot; /&gt;
  
    &lt;TextView
            android:id=&quot;@+id/txt1&quot;
            android:layout_width=&quot;wrap_content&quot;
            android:layout_height=&quot;wrap_content&quot;
            android:layout_alignParentBottom=&quot;true&quot;
            android:layout_alignParentLeft=&quot;true&quot;
            android:layout_marginBottom=&quot;62dp&quot;
            android:layout_marginLeft=&quot;48dp&quot;
            android:textAppearance=&quot;?android:attr/textAppearanceLarge&quot;
            android:textColor=&quot;#000000&quot; /&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  <p>Java file:</p>
  <pre class="lang-java prettyprint-override"><code>package com.example.flip3d;
  
  import android.app.Activity;
  import android.content.Intent;
  import android.graphics.drawable.Drawable;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ImageView;
  import android.widget.Toast;
  
  
  public class Cards extends Activity {
  
    ImageView img1;
    ImageView img2;
    ImageView image;
  
    @Override
    protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.cards);
  
      img1 =(ImageView) findViewById(R.id.img1);
      img2 =(ImageView) findViewById(R.id.img2);
      image =(ImageView) findViewById(R.id.ImageView01);
  
      img1.setOnClickListener(new View.OnClickListener() {
  
        public void onClick(View arg0) {
  
          image.setImageResource(R.drawable.myfirstimage);
          Intent startyou = new Intent(&quot;com.example.flip3d.FLIP3D&quot;);
          startActivity(startyou);
        }
      });
  
      img2.setOnClickListener(new View.OnClickListener() {
  
        public void onClick(View view) {
          image.setImageResource(R.drawable.may2ndimage);
  
          Toast.makeText(Cards.this, &quot;Card Selected&quot;, Toast.LENGTH_SHORT).show();
  
          Intent startyou = new Intent(&quot;com.example.flip3d.FLIP3D&quot;);
          startActivity(startyou);
        }
      });
  
    }
  
  }
  </code></pre>
  <p><a href="http://i820.photobucket.com/albums/zz130/lestah23/untitled-1_zps33fa9be5.png" rel="nofollow noreferrer">My logcat message.</a></p>
  <p>When I run this code on my phone. An error occurred and when I check the logcat it says: that I'm having error with <code>setImageResource();</code>.</p>
  <p>What should I do? I'm a beginner in Android programming.</p>
  <p>Thanks in advance.</p>