title: Android app crashes on onClickListener
body: <p>I have this app which is a simple lottery system but whenever I try pressing one of the buttons the app freezes then crashes and I don't know why. The program doesn't give me errors so it's really confusing. I saw some things about it being a problem with the layout but I can't figure out what it is. I will answer the page Layout in a comment under the question. Thanks in advance.</p>
  
  <p>Here's the page script:</p>
  
  <pre><code>package com.example.myapplication;
  
  import android.graphics.Color;
  import android.icu.text.NumberFormat;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.TextView;
  import java.util.*;
  import java.math.*;
  
  import org.w3c.dom.Text;
  
  import javax.xml.transform.Result;
  
  public class Lottery extends AppCompatActivity {
      Button Check, Random;
      EditText User1;
      TextView Balance2, ResultText;
      int  Balance1 = 500;
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_lottery);
          Check = (Button)findViewById(R.id.CheckNumbers);
          Random = (Button)findViewById(R.id.RandomNumber);
          User1 = findViewById(R.id.PickNumber);
          Balance2 = (TextView)findViewById(R.id.Balance);
          ResultText = (TextView)findViewById(R.id.Result);
          ResultText.setVisibility(View.GONE);
  
         Balance2.setText("Balance: $500");
  
          Check.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                  int User=Integer.parseInt(String.valueOf(User1));
                  if(User1.toString().trim().equals("")){
                      ResultText.setBackgroundColor(Color.RED);
                      ResultText.setText("Please Enter a Number");
                      ResultText.setVisibility(View.VISIBLE);
  
                  }
                  else if(User &gt; 100 || User &lt; 1){
                      ResultText.setBackgroundColor(Color.RED);
                      ResultText.setText("Please Enter a Number between 1 and 100");
                      ResultText.setVisibility(View.VISIBLE);
                  }
                  else {
                      int answer = (int)((Math.random()*100)+1);
                      int placeholder = answer % 10;
                      int AnswerTens = (answer - placeholder)/10;
                      int AnswerOnes = placeholder;
                      placeholder = User %10;
                      int UserTens = (User- placeholder)/10;
                      int UserOnes = placeholder;
  
                      if(User == answer){
                          ResultText.setBackgroundColor(Color.GREEN);
                          ResultText.setText("Correct!!! The Number was "+User+" $1000 has been added to your account");
                          ResultText.setVisibility(View.VISIBLE);
                          Balance1 += 1000;
                          Balance2.setText("Balance: $ "+  Balance1);
                      }
                      else if((UserTens == AnswerOnes)&amp;&amp;(UserOnes == AnswerTens)){
                          ResultText.setBackgroundColor(Color.GREEN);
                          ResultText.setText(" Somewhat Correct! The digit were correct but in the wrong order The answer was "+answer+" $500 has been added to your account");
                          ResultText.setVisibility(View.VISIBLE);
                          Balance1 += 500;
                          Balance2.setText("Balance: $ "+  Balance1);
                      }
                      else if((UserTens == AnswerTens)|| (UserTens == AnswerOnes)||(UserOnes == AnswerOnes)||(UserOnes==AnswerTens)){
                          ResultText.setBackgroundColor(Color.GREEN);
                          ResultText.setText("Kinda Correct! One digit was  correct The answer was "+answer+" $100 has been added to your account");
                          ResultText.setVisibility(View.VISIBLE);
                          Balance1 += 100;
                          Balance2.setText("Balance: $ "+  Balance1);
                      }
                      else{
                          ResultText.setBackgroundColor(Color.RED);
                          ResultText.setText("Incorrect the Number was "+answer);
                          ResultText.setVisibility(View.VISIBLE);
                      }
  
  
                  }
              }
          });
          Random.setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View view) {
                 int answer = (int)((Math.random()*100)+1);
  
                  User1.setText(answer);
              }
          });
      }
  }
  </code></pre>