title: Fatal exception (java.lang.IllegalStateException)
body: <p>I've been trying to search for an answer but the only thing i understood is there's something wrong at line 22 of my code, but i don't get why. I'm sure it's something stupid, but i started yesterday to code android, so forgive me please!</p>
  
  <p>My code is:</p>
  
  <pre><code>import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.CheckBox;
  import android.widget.Toast;
  
  public class Benvenuto extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_benvenuto);
         }
  
  
  
  public void entra(View view) {
      Intent entra1 = new Intent(this, domande1.class);
      boolean checked = ((CheckBox) view).isChecked();
  
      switch (view.getId()) {
          case R.id.condizioni:
              if (checked)
                  startActivity(entra1);
              else
                  Toast.makeText(this, "Devi approvare termini e condizioni prima di procedere!", Toast.LENGTH_SHORT).show();
              break;
      }
  
  }
  }
  </code></pre>
  
  <p>So, basically, user has to agree to terms and conditions. If he agrees, good, he jumps to the next activity. If not, a toast appears!</p>
  
  <p>But the app crashes when i press the button (before adding the checkbox, it worked fine).</p>
  
  <p>The error i get is </p>
  
  <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main
                Process: com.suspicio.turboscuse, PID: 547
                java.lang.IllegalStateException: Could not execute method for android:onClick
                    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:293)
                    at android.view.View.performClick(View.java:5201)
                    at android.view.View$PerformClick.run(View.java:21209)
                    at android.os.Handler.handleCallback(Handler.java:739)
                    at android.os.Handler.dispatchMessage(Handler.java:95)
                    at android.os.Looper.loop(Looper.java:148)
                    at android.app.ActivityThread.main(ActivityThread.java:5525)
                    at java.lang.reflect.Method.invoke(Native Method)
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730)
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620)
                 Caused by: java.lang.reflect.InvocationTargetException
                    at java.lang.reflect.Method.invoke(Native Method)
                    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288)
                    at android.view.View.performClick(View.java:5201) 
                    at android.view.View$PerformClick.run(View.java:21209) 
                    at android.os.Handler.handleCallback(Handler.java:739) 
                    at android.os.Handler.dispatchMessage(Handler.java:95) 
                    at android.os.Looper.loop(Looper.java:148) 
                    at android.app.ActivityThread.main(ActivityThread.java:5525) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
                 Caused by: java.lang.ClassCastException: android.support.v7.widget.AppCompatButton cannot be cast to android.widget.CheckBox
                    at com.suspicio.turboscuse.Benvenuto.entra(Benvenuto.java:22)
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at android.support.v7.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:288) 
                    at android.view.View.performClick(View.java:5201) 
                    at android.view.View$PerformClick.run(View.java:21209) 
                    at android.os.Handler.handleCallback(Handler.java:739) 
                    at android.os.Handler.dispatchMessage(Handler.java:95) 
                    at android.os.Looper.loop(Looper.java:148) 
                    at android.app.ActivityThread.main(ActivityThread.java:5525) 
                    at java.lang.reflect.Method.invoke(Native Method) 
                    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:730) 
                    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:620) 
  </code></pre>
  
  <p>Can you help me please?</p>