title: ImageView.setOnClickListener ERROR null object reference
body: <p>I am getting an error after adding setonclick listener method:</p>
  
  <p>CODE:</p>
  
  <pre><code>ImageView first, second_img;
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          first = (ImageView) findViewById(R.id.first_image);
          second_img = (ImageView)findViewById(R.id.second_image);
  
          setContentView(R.layout.main);
  
          first.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  Intent get_img  = new Intent();
                  get_img.setType("image/*");
                  get_img.setAction(Intent.ACTION_GET_CONTENT);
                  startActivityForResult(Intent.createChooser(get_img, "Select Picture"), 1);
              }
          });
  
          Bitmap bmp = BitmapFactory.decodeResource(getResources(), R.drawable.anonymous);
          ByteArrayOutputStream stream = new ByteArrayOutputStream();
          bmp.compress(Bitmap.CompressFormat.PNG, 100, stream);
          byte[] bytes = stream.toByteArray();
  
          //for(byte bite: bytes){
          //    System.out.println("@@@: " + bite);
          //}
  
          Bitmap second_bmp = BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
          second_img.setImageBitmap(second_bmp);
      }
  </code></pre>
  
  <p>ERROR:</p>
  
  <pre><code> Process: com.example.example, PID: 3100
      java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.example/com.example.example.example}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.ImageView.setOnClickListener(android.view.View$OnClickListener)' on a null object reference
  </code></pre>
  
  <p>I don't know what is going on, someone help me, I would appreciate your help, Thanks.</p>