title: Android checkBox onClick app doesn't work, stops unexpectedly?
body: <p>So,</p>
  
  <p>I am building a basic app which has 2 activivities. Now, the first one works well, the second one does not. It does not show any errors while I edit the codes, but when I run the app and when I am in the second acitivity it gives me an annoying error. Saying "Stops unexpectedly...." You know. I tried debugging but failed. In the second activity called Troll.java I should be able to check a checkbox and when I do that a text is supposed to change to something else. It says stops unexpe.....</p>
  
  <p>main.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  xmlns:tools="http://schemas.android.com/tools"
  android:padding="0dp"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:gravity="center_horizontal"
  android:paddingBottom="@dimen/activity_vertical_margin"
  android:paddingLeft="@dimen/activity_horizontal_margin"
  android:paddingRight="@dimen/activity_horizontal_margin"
  android:paddingTop="@dimen/activity_vertical_margin"
  tools:context=".MainActivity" &gt;
  
  &lt;include
   android:layout_centerInParent="true"
   android:layout_width="match_parent"
   android:layout_height="match_parent"
   layout="@layout/resuable_pizza_layout" /&gt;
  
  &lt;TextView
      android:id="@+id/display"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_alignParentTop="true"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="105dp"
      android:text="@string/display"
      android:textColor="#FFFFFF"
      android:textSize="18sp" /&gt;
  
  &lt;ImageView
      android:id="@+id/lol"
      android:onClick="onlol"
      android:contentDescription="@string/lol2"
      android:layout_width="wrap_content"
      android:layout_height="wrap_content"
      android:layout_below="@+id/display"
      android:layout_centerHorizontal="true"
      android:layout_marginTop="66dp"
      android:src="@drawable/lol" /&gt;
  </code></pre>
  
  <p></p>
  
  <p>troll.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
  android:layout_width="match_parent"
  android:layout_height="match_parent"
  android:background="#FF69B4"
  android:orientation="vertical" &gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="wrap_content"
      android:gravity="center" &gt;
  
      &lt;CheckBox
          android:id="@+id/box1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:onClick="onChecked1"
          android:text="@string/ch1"
          android:textColor="#000000" /&gt;
  
      &lt;CheckBox
          android:id="@+id/box2"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:onClick="onChecked2"
          android:text="@string/ch2"
          android:textColor="#000000" /&gt;
  &lt;/LinearLayout&gt;
  
  &lt;LinearLayout
      android:layout_width="match_parent"
      android:layout_height="0dp"
      android:gravity="center"
      android:layout_weight="0.26" &gt;
  
      &lt;TextView
          android:id="@+id/textView1"
          android:textColor="#000000"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:text="@string/trollFace"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
  &lt;/LinearLayout&gt;
  
  &lt;/LinearLayout&gt;
  </code></pre>
  
  <p>mainActitvity.java :</p>
  
  <pre><code>package com.example.pizza2;
  
  import android.os.Bundle;
  import android.app.Activity;
  import android.content.Intent;
  import android.view.Menu;
  import android.view.View;
  import android.widget.CheckBox;
  import android.widget.TextView;
  
  public class MainActivity extends Activity {
  
  CheckBox pepp, cheese;
  TextView tv;
  
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      pepp = (CheckBox) findViewById(R.id.check1);
      cheese = (CheckBox) findViewById(R.id.check2);
      tv = (TextView) findViewById(R.id.display);
  
  }
  
  public void onShow(View view){
      StringBuilder str = new StringBuilder();
      if (pepp.isChecked() &amp;&amp; cheese.isChecked()){
          str.append("Pepperoni, extra cheese pizza!");
      }
  
      else if (pepp.isChecked()){
          str.append("Pepperoni pizza!");
      }
  
      else if (cheese.isChecked()){
          str.append("Extra cheese pizza!");
      }
  
      tv.setText(str);
  }
  
  public void onlol(View view){
      Intent intent = new Intent(this, Troll.class);
      startActivity(intent);
  }
  
  @Override
  public boolean onCreateOptionsMenu(Menu menu) {
      // Inflate the menu; this adds items to the action bar if it is present.
      getMenuInflater().inflate(R.menu.main, menu);
      return true;
  }
  
      }
  </code></pre>
  
  <p>Troll.java:</p>
  
  <pre><code>package com.example.pizza2;
  
  import android.app.Activity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.CheckBox;
  import android.widget.TextView;
  
   public class Troll extends Activity{
  
  CheckBox box11, box22;
  TextView tv;
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      // TODO Auto-generated method stub
      super.onCreate(savedInstanceState);
      setContentView(R.layout.troll);
      box11 = (CheckBox) findViewById(R.id.box1);
      box22 = (CheckBox) findViewById(R.id.box2);
      tv = (TextView) findViewById(R.id.display);
  
  }
  
  public void onChecked1(View view){
  
      StringBuilder str = new StringBuilder();
  
      if(box11.isChecked()){
      str.append("Lol bro!");
      }
  
      tv.setText(str);
  }//end of "onChecked1"  
  
  
      public void onChecked2(View view){
          StringBuilder str = new StringBuilder();
          if(box22.isChecked()){
              str.append("XD XD Kaki");
          }
          tv.setText(str);
  
      } //end of "onChecked2" 
   }
  </code></pre>