title: Android Error: NullPointerException being thrown
body: <p>My code consists of an XML gridview in which 64 imageviews are laid out in a chessboard pattern. My java is supposed to monitor for clicks on those imageViews with actual images inside of them and then execute the supplied code. </p>
  
  <p>However, at runtime my emulator is presenting me with a dialogue box saying "Unfortunately, chessboard stopped working" and logcat is throwing a NullPointerException like so: <code>java.lang.NullPointerException: Attempt to invoke virtual method 'android.view.View android.app.Activity.findViewById(int)' on a null object reference</code></p>
  
  <p>I'm not not sure where the null is being generated. I know that I'm checking for null but I don't see how that could be generating the error.</p>
  
  <pre><code>import android.app.Activity;
  import android.support.v7.app.ActionBarActivity;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuItem;
  import android.view.View;
  import android.widget.ImageView;
  import android.widget.Toast;
  import android.view.View.OnClickListener;
  
  
  public class chessboard extends ActionBarActivity {
  
  
      public Activity board;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.board);
  
          final ImageView block2 = (ImageView) board.findViewById(R.id.block2);
          block2.setClickable(true);
          block2.setOnClickListener(new OnClickListener() {
                  public void onClick(View v) {
                      if (block2.getTag() != (null)) {
                          Toast.makeText(getBaseContext(), "Check", Toast.LENGTH_LONG).show();
  
                      }
                  }
              });
  
      }
  </code></pre>