title: Android - Get the image's resource
body: <p>My question is how do you check the image's resource? In my <code>onClick</code> method there's a countdown (which I summarized to avoid long post) which on every tick randomizes a boolean. If true, <code>img1</code> resource is set to <code>headAppear.jpg</code>. If false, <code>img1</code> sets to <code>headHide.jpg</code>.</p>
  
  <p>What code will I put in the <code>onClick()</code> to check whether the picture is <code>headAppear</code> or <code>headHide</code>? What I want to do is, if I clicked <code>img1</code> and it shows <code>headAppear</code>, <code>score++</code>. Else, if it shows <code>headHide</code>, <code>score--</code>.</p>
  
  <hr>
  
  <p>In my <code>onCreate()</code> method:</p>
  
  <pre><code>ImageView img1 = (ImageView) findViewById(R.id.pic1);
  img1.setOnClickListener( this );
  
  //Countdown method here
  var = aRandom.nextBoolean();
  if( var == true ) {
     img1.setImageResource( R.drawable.headAppear );
  } else {
     img1.setImageResource( R.drawable.headHide );
  }
  //End of countdown method
  </code></pre>
  
  <hr>
  
  <p>In my <code>onClick(View v)</code> method:</p>
  
  <pre><code>if (v == img1) {
     //insert code here
  }
  </code></pre>