title: my application stops when I start it
body: <p>So I just started programming in java, and tried to make a TicTicToeGame, which succeeded :) The problem is, that you can only play 1 game of TicTacToe, so I wanted to make a button to restart the game and a button to quit the game. Since I added this and try to run it on my phone it crashes when I start it up. Here is my MainActivity.java:</p>
  
  <pre><code>package com.example.testjk;
  
  import android.support.v7.app.ActionBarActivity;
  import android.content.Context;
  import android.graphics.Color;
  import android.inputmethodservice.ExtractEditText;
  import android.os.Bundle;
  import android.view.Menu;
  import android.view.MenuInflater;
  import android.view.MenuItem;
  import android.view.View;
  import android.view.View.OnClickListener;
  import android.widget.Button;
  import android.widget.EditText;
  import android.widget.ImageButton;
  import android.widget.TextView;
  import android.widget.Toast;
  
  
  
  public class MainActivity extends ActionBarActivity implements OnClickListener{
  
      private TicTacToeGame mGame;
  
      private Button mBoardButtons[];
  
      private TextView mInfoTextView;
      private TextView mHumanCount;
      private TextView mTieCount;
      private TextView mAndroidCount;
  
      private int mHumanCounter = 0;
      private int mTieCounter = 0;
      private int mAndroidCounter = 0;
  
      private boolean mHumanFirst = true;
      private boolean mGameOver = false;
  
  
  
  
      @Override
      protected void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_main);
  
          mBoardButtons = new Button[mGame.getBOARD_SIZE()];
          mBoardButtons[0] = (Button) findViewById(R.id.one);
          mBoardButtons[1] = (Button) findViewById(R.id.two);
          mBoardButtons[2] = (Button) findViewById(R.id.three);
          mBoardButtons[3] = (Button) findViewById(R.id.four);
          mBoardButtons[4] = (Button) findViewById(R.id.five);
          mBoardButtons[5] = (Button) findViewById(R.id.six);
          mBoardButtons[6] = (Button) findViewById(R.id.seven);
          mBoardButtons[7] = (Button) findViewById(R.id.eight);
          mBoardButtons[8] = (Button) findViewById(R.id.nine);
  
          Button mTen = (Button) findViewById(R.id.ten);
          mTen.setOnClickListener((OnClickListener) this);
          Button mEleven = (Button) findViewById(R.id.eleven);
          mEleven.setOnClickListener((OnClickListener) this);
  
  
          mInfoTextView = (TextView) findViewById(R.id.information);
          mHumanCount = (TextView) findViewById(R.id.humancount);
          mTieCount = (TextView) findViewById(R.id.tiesCount);
          mAndroidCount = (TextView) findViewById(R.id.androidCount);
  
          mHumanCount.setText(Integer.toString(mHumanCounter));
          mTieCount.setText(Integer.toString(mTieCounter));
          mHumanCount.setText(Integer.toString(mAndroidCounter));
  
          mGame = new TicTacToeGame();
  
          startNewGame();
  
  
      }
  
      @Override
      public void onClick(View v)
      {
          switch (v.getId())
          {
          case R.id.ten:
  
              startNewGame();
              break;
  
          case R.id.eleven:
  
              MainActivity.this.finish();
              break;
  
          }
      }
  
  
  
      private void startNewGame()
      {
          mGame.clearBoard();
  
          for (int i = 0; i &lt; mBoardButtons.length; i++)
          {
              mBoardButtons[i].setText("");
              mBoardButtons[i].setEnabled(true);
              mBoardButtons[i].setOnClickListener(new ButtonClickListener(i));
  
          }
          if (mHumanFirst)
          {
              mInfoTextView.setText(R.string.first_human);
              mHumanFirst = false;
          }
          else
          {
              mInfoTextView.setText(R.string.turn_computer);
              int move = mGame.getComputerMove();
              setMove(mGame.ANDROID_PLAYER, move);
              mHumanFirst = true;
          }
      }
  
      private class ButtonClickListener implements View.OnClickListener
      {
          int location;
  
          public ButtonClickListener(int location)
          {
              this.location = location;
          }
  
          public void onClick(View view)
          {
              if (!mGameOver)
              {
                  if(mBoardButtons[location].isEnabled())
                  {
                      setMove(mGame.HUMAN_PLAYER, location);
  
                      int winner = mGame.checkForWinner();
  
                      if (winner == 0)
                      {
                          mInfoTextView.setText(R.string.turn_computer);
                          int move = mGame.getComputerMove();
                          setMove(mGame.ANDROID_PLAYER, move);
                          winner = mGame.checkForWinner();
  
                      }
                      if (winner == 0)
                              mInfoTextView.setText(R.string.turn_human);
                      else if (winner == 1)
                      {
                          mInfoTextView.setText(R.string.result_tie);
                          mTieCounter++;
                          mTieCount.setText(Integer.toString(mTieCounter));
                          mGameOver = true;
                      }       
                      else if (winner ==2)
                      {
                          mInfoTextView.setText(R.string.result_human_wins);
                          mHumanCounter++;
                          mHumanCount.setText(Integer.toString(mHumanCounter));
                          mGameOver = true;
                      }
                      else if (winner ==3)
                      {
                          mInfoTextView.setText(R.string.result_android_wins);
                          mAndroidCounter++;
                          mAndroidCount.setText(Integer.toString(mAndroidCounter));
                          mGameOver = true;
                      }
                  }
              }
          }
      }
  
      private void setMove(char player, int location)
      {
          mGame.setMove(player,location);
          mBoardButtons[location].setEnabled(false);
          mBoardButtons[location].setText(String.valueOf(player));
          if (player == mGame.HUMAN_PLAYER)
              mBoardButtons[location].setTextColor(Color.GREEN);
          else
          {
              mBoardButtons[location].setTextColor(Color.RED);
          }
      }
  
  }
  </code></pre>
  
  <p>This is my strings.xml:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;resources&gt;
  
      &lt;string name="app_name"&gt;testjk&lt;/string&gt;
      &lt;string name="hello_world"&gt;Hello world!&lt;/string&gt;
      &lt;string name="turn_human"&gt;Jouw beurt.&lt;/string&gt;
      &lt;string name="first_human"&gt;Jij mag eerst beginnen.&lt;/string&gt;
      &lt;string name="turn_computer"&gt;computer is aan het nadenken&lt;/string&gt;
      &lt;string name="result_tie"&gt;Gelijkspel!&lt;/string&gt;
      &lt;string name="result_human_wins"&gt;net aan gewonnen!&lt;/string&gt;
      &lt;string name="result_android_wins"&gt;sukkel!&lt;/string&gt;
      &lt;string name="one"&gt;1&lt;/string&gt;
      &lt;string name="two"&gt;2&lt;/string&gt;
      &lt;string name="three"&gt;3&lt;/string&gt;
      &lt;string name="four"&gt;4&lt;/string&gt;
      &lt;string name="five"&gt;5&lt;/string&gt;
      &lt;string name="six"&gt;6&lt;/string&gt;
      &lt;string name="seven"&gt;7&lt;/string&gt;
      &lt;string name="eight"&gt;8&lt;/string&gt;
      &lt;string name="nine"&gt;9&lt;/string&gt;
      &lt;string name="ten"&gt;nieuw spel&lt;/string&gt;
      &lt;string name="eleven"&gt;stoppen&lt;/string&gt;
      &lt;string name="info"&gt;Info&lt;/string&gt;
      &lt;string name="human"&gt;JIJ:  &lt;/string&gt;
      &lt;string name="ties"&gt;Gelijkspel:  &lt;/string&gt;
      &lt;string name="android"&gt;Computer:  &lt;/string&gt;
      &lt;string name="contact_heading"&gt;Contact Informatie&lt;/string&gt;
      &lt;string name="action_settings"&gt;Settings&lt;/string&gt;
      &lt;string name="contact_info"&gt;
  
          &lt;b&gt;Name:&lt;/b&gt; Wouter\n
          &lt;b&gt;Achternaam&lt;/b&gt; de Jong\n
          &lt;b&gt;Email&lt;/b&gt; woutter@live.nl
          &lt;/string&gt;
          &lt;string name="about_heading"&gt;over &lt;/string&gt;
          &lt;string name="TicTacToeGame"&gt;Boter Kaas en Eieren van wouter de jong&lt;/string&gt;
  
  
  &lt;/resources&gt;
  </code></pre>
  
  <p>This is my activity_main.xml:</p>
  
  <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
      xmlns:tools="http://schemas.android.com/tools"
      android:layout_width="match_parent"
      android:layout_height="match_parent"
      android:layout_marginTop="26dp"
      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="com.example.testjk.MainActivity" &gt;
  
      &lt;TableLayout
          android:id="@+id/PlayArea"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_alignParentTop="true"
          android:layout_marginTop="10dp" &gt;
  
  
          &lt;TableRow
              android:id="@+id/tableRow1"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="clip_horizontal" &gt;
  
              &lt;Button
                  android:id="@+id/one"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/one"
                  android:textSize="70dp" /&gt;
  
              &lt;Button
                  android:id="@+id/two"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/two"
                  android:textSize="70dp" /&gt;
  
              &lt;Button
                  android:id="@+id/three"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/three"
                  android:textSize="70dp" /&gt;
          &lt;/TableRow&gt;
  
          &lt;TableRow
              android:id="@+id/tableRow2"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="clip_horizontal" &gt;
  
              &lt;Button
                  android:id="@+id/four"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/four"
                  android:textSize="70dp" /&gt;
  
              &lt;Button
                  android:id="@+id/five"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/five"
                  android:textSize="70dp" /&gt;
  
              &lt;Button
                  android:id="@+id/six"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/six"
                  android:textSize="70dp" /&gt;
          &lt;/TableRow&gt;
  
          &lt;TableRow
              android:id="@+id/tableRow3"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:gravity="clip_horizontal" &gt;
  
              &lt;Button
                  android:id="@+id/seven"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/seven"
                  android:textSize="70dp" /&gt;
  
              &lt;Button
                  android:id="@+id/eight"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/eight"
                  android:textSize="70dp" /&gt;
  
              &lt;Button
                  android:id="@+id/nine"
                  android:layout_width="100dp"
                  android:layout_height="100dp"
                  android:text="@string/nine"
                  android:textSize="70dp" /&gt;
          &lt;/TableRow&gt;
      &lt;/TableLayout&gt;
  
      &lt;TableRow
          android:id="@+id/tableRow4"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_below="@+id/information"
          android:layout_centerHorizontal="true"
          android:gravity="center_horizontal|clip_horizontal|fill_horizontal" &gt;
  
          &lt;TextView
              android:id="@+id/human"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/human" /&gt;
  
          &lt;TextView
              android:id="@+id/humancount"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginRight="10dp" /&gt;
  
          &lt;TextView
              android:id="@+id/ties"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/ties" /&gt;
  
          &lt;TextView
              android:id="@+id/tiesCount"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:layout_marginRight="10dp" /&gt;
  
          &lt;TextView
              android:id="@+id/androidcount"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content"
              android:text="@string/android" /&gt;
  
          &lt;TextView
              android:id="@+id/androidCount"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" /&gt;
      &lt;/TableRow&gt;
  
      &lt;TextView
          android:id="@+id/information"
          android:layout_width="match_parent"
          android:layout_height="wrap_content"
          android:layout_alignLeft="@+id/PlayArea"
          android:layout_below="@+id/PlayArea"
          android:gravity="center"
          android:text="@string/info"
          android:textAppearance="?android:attr/textAppearanceLarge" /&gt;
  
      &lt;TableLayout
          android:id="@+id/tableLayout1"
          android:layout_width="wrap_content"
          android:layout_height="wrap_content"
          android:layout_alignParentLeft="true"
          android:layout_below="@+id/tableRow4"
          android:layout_marginTop="32dp" &gt;
  
          &lt;TableRow
              android:id="@+id/tableRow5"
              android:layout_width="wrap_content"
              android:layout_height="wrap_content" &gt;
  
              &lt;Button
                  android:id="@+id/ten"
                  android:layout_width="120dp"
                  android:layout_height="wrap_content"
                  android:text="@string/ten" /&gt;
  
              &lt;Button
                  android:id="@+id/eleven"
                  android:layout_width="120dp"
                  android:layout_height="wrap_content"
                  android:layout_marginLeft="50dp"
                  android:text="@string/eleven" /&gt;
  
          &lt;/TableRow&gt;
      &lt;/TableLayout&gt;
  
  &lt;/RelativeLayout&gt;
  </code></pre>
  
  <p>TicTacToeGame.java:</p>
  
  <pre><code>package com.example.testjk;
  
  import java.util.Random;
  
  public class TicTacToeGame {
  
      private char mBoard[];
      private final static int BOARD_SIZE = 9;
  
      public static final char HUMAN_PLAYER = 'X';
      public static final char ANDROID_PLAYER = '0';
      public static final char EMPTY_SPACE = ' ';
  
      private Random mRand;
  
      public static int getBOARD_SIZE() {
          return BOARD_SIZE;
      }
  
      public TicTacToeGame(){
          mBoard = new char[BOARD_SIZE];
  
          for (int i = 0; i &lt; BOARD_SIZE; i++)
              mBoard[i] = EMPTY_SPACE;
  
          mRand = new Random();
      }
  
      public void clearBoard()
      {
          for (int i = 0;i &lt; BOARD_SIZE; i++)
          {
              mBoard[i] = EMPTY_SPACE;
          }
      }
  
      public void setMove(char player, int location)
      {
          mBoard[location] = player;
      }
  
      public int getComputerMove()
      {
          int move;
  
          for (int i = 0; i &lt; getBOARD_SIZE(); i++)
          {
              if (mBoard[i] != HUMAN_PLAYER &amp;&amp; mBoard[i] != ANDROID_PLAYER)
              {
                  char curr = mBoard[i];
                  mBoard[i] = ANDROID_PLAYER;
                  if (checkForWinner() == 3)
                  {
                      setMove(ANDROID_PLAYER, i);
                      return i;
                  }
                  else 
                      mBoard[i] = curr;
              }
          }
          for (int i = 0; i &lt; getBOARD_SIZE(); i++)
          {
              if (mBoard[i] != HUMAN_PLAYER &amp;&amp; mBoard[i] != ANDROID_PLAYER)
              {
                  char curr = mBoard[i];
                  mBoard[i] = HUMAN_PLAYER;
                  if (checkForWinner() == 2)
                  {
                      setMove(ANDROID_PLAYER, i);
                      return i;
                  }
                  else 
                      mBoard[i] = curr;
              }
          }
          do
          {
              move = mRand.nextInt(getBOARD_SIZE());
          }while (mBoard[move]==HUMAN_PLAYER || mBoard[move] == ANDROID_PLAYER);
  
              setMove(ANDROID_PLAYER, move);
          return move;
      }
      public int checkForWinner()
      {
          for (int i=0;i&lt;=6;i+=3)
          {
              if (mBoard[i] == HUMAN_PLAYER &amp;&amp; 
                  mBoard[i+1] == HUMAN_PLAYER &amp;&amp; 
                  mBoard[i+2] == HUMAN_PLAYER)
                  return 2;
              if (mBoard[i] == ANDROID_PLAYER &amp;&amp; 
                  mBoard[i+1] == ANDROID_PLAYER &amp;&amp; 
                  mBoard[i+2] == ANDROID_PLAYER)
                  return 3;
          }
          for (int i = 0; i &lt;=2; i++)
          {
              if (mBoard[i] == HUMAN_PLAYER &amp;&amp;
                  mBoard[i+3] == HUMAN_PLAYER &amp;&amp;
                  mBoard[i+6] == HUMAN_PLAYER)
                  return 2;
              if (mBoard[i] == ANDROID_PLAYER &amp;&amp;
              mBoard[i+3] == ANDROID_PLAYER &amp;&amp;
              mBoard[i+6] == ANDROID_PLAYER)
                  return 3;
  
          }
          if((mBoard[0] == HUMAN_PLAYER &amp;&amp;
                  mBoard[4] == HUMAN_PLAYER &amp;&amp;
                  mBoard[8] == HUMAN_PLAYER)|| 
                  (mBoard[2] == HUMAN_PLAYER &amp;&amp;
                  mBoard[4] == HUMAN_PLAYER &amp;&amp;
                  mBoard[6] == HUMAN_PLAYER))
          return 2;
      if((mBoard[0] == ANDROID_PLAYER &amp;&amp;
              mBoard[4] == ANDROID_PLAYER &amp;&amp;
              mBoard[8] == ANDROID_PLAYER)|| 
              (mBoard[2] == ANDROID_PLAYER &amp;&amp;
              mBoard[4] == ANDROID_PLAYER &amp;&amp;
              mBoard[6] == ANDROID_PLAYER))
          return 3;
  
  
      for (int i = 0; i &lt; getBOARD_SIZE(); i++)
      {
          if (mBoard[i] != HUMAN_PLAYER &amp;&amp; mBoard[i] != ANDROID_PLAYER)
              return 0;
      }
      return 1;
      }
  }
  </code></pre>
  
  <p>AndroidManiFest.xml in my bin/res folder:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.example.testjk"
      android:versionCode="1"
      android:versionName="1.0" &gt;
  
      &lt;uses-sdk
          android:minSdkVersion="11"
          android:targetSdkVersion="21" /&gt;
  
      &lt;application
          android:allowBackup="true"
          android:icon="@drawable/ic_hoi"
          android:label="@string/app_name"
          android:theme="@style/AppTheme" &gt;
          &lt;activity
              android:name=".MainActivity"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN" /&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>game_menu.xml in my res/menu folder:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;menu xmlns:android="http://schemas.android.com/apk/res/android" &gt;
  
  
  
  
  
  &lt;/menu&gt;
  </code></pre>
  
  <p>Those are all my classes I edited.
  And this is the logcat I get: <a href="http://i.imgur.com/XhcNyy7.png" rel="nofollow">http://i.imgur.com/XhcNyy7.png</a></p>