title: TicTacToe how to count wins, counter - help needed
body: <p>I'm stuck. What I need is counter to wins values.
  I did tictactoe by this tutorial : <a href="http://hubpages.com/technology/tictactoe" rel="nofollow noreferrer">http://hubpages.com/technology/tictactoe</a>. I've complete it and now I'd like to add something by myself, and it's just a counter of how many times someone won.</p>
  
  <pre><code>//if mWinner = CIRCLE
      //increase @+id/cross_wins by 1
  //if mWinner = CROSS
      //increase @+id/circles_wins by 1
  //else increase @+id/draws by 1
  </code></pre>
  
  <p>that is all what I want, could you show me how to code it proper?</p>
  
  <p><a href="https://i.stack.imgur.com/dzua2.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dzua2.jpg" alt="I want the &quot;0&quot; on this to change, if crosses,circles wins the game or it&#39;s a draw, just to tick +1"></a></p>
  
  <pre><code>package com.example.jkaminski.myapplication;
  
  import android.content.Intent;
  import android.support.v7.app.AppCompatActivity;
  import android.os.Bundle;
  import android.view.View;
  import android.widget.ImageView;
  import android.widget.LinearLayout;
  import android.widget.TextView;
  import android.widget.Toast;
  
  public class GameActivity extends AppCompatActivity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.activity_main);
      makeScreen();
      initialize();
  }
  
  private void makeScreen() {
      View decorView = getWindow().getDecorView();
      int uiOptions = View.SYSTEM_UI_FLAG_FULLSCREEN;
      decorView.setSystemUiVisibility(uiOptions);
      getSupportActionBar().hide();
  }
  
  private ImageView[] mBlocks = new ImageView[9];
  private TextView mDisplay;
  private LinearLayout mExit, mReplay;
  
  private enum TURN {CIRCLE, CROSS}
  
  private TURN mTurn;
  private int mExitCounter = 0;
  private int mStatusCounter = 0;
  
  private void initialize() {
      mExit = (LinearLayout) findViewById(R.id.exit);
      mExit.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              if (mExitCounter == 1) {
                  finish();
                  System.exit(0);
              } else {
                  mExitCounter++;
                  Toast.makeText(getApplicationContext(), "Naciśnij ponownie aby wyjść", Toast.LENGTH_SHORT).show();
              }
          }
      });
      mDisplay = (TextView) findViewById(R.id.display_board);
      mReplay = (LinearLayout) findViewById(R.id.replay);
      mReplay.setOnClickListener(new View.OnClickListener() {
          @Override
          public void onClick(View v) {
              Intent starter = getIntent();
              finish();
              starter.setFlags(Intent.FLAG_ACTIVITY_NO_ANIMATION);
              startActivity(starter);
          }
      });
      for (int position = 0; position &lt; 9; position++) {
          int resId = getResources().getIdentifier("block_" + (position + 1), "id", getPackageName());
          mBlocks[position] = (ImageView) findViewById(resId);
          final int finalPosition = position;
          mBlocks[position].setOnClickListener(new View.OnClickListener() {
              @Override
              public void onClick(View v) {
                  switchTurn(finalPosition);
              }
          });
  
      }
  }
  
  private void switchTurn(int position) {
      if (mTurn == TURN.CIRCLE) {
          mBlocks[position].setImageResource(R.drawable.circle);
          mBlocks[position].setId(GameLogic.CIRCLE);
          mTurn = TURN.CROSS;
          mDisplay.setText("teraz KRZYŻYK");
      } else {
          mBlocks[position].setImageResource(R.drawable.cross);
          mBlocks[position].setId(GameLogic.CROSS);
          mTurn = TURN.CIRCLE;
          mDisplay.setText("teraz KÓŁKO");
      }
      mBlocks[position].setEnabled(false);
      mStatusCounter++;
      if (GameLogic.isCompleted(position + 1, mBlocks)) {
          mDisplay.setText(GameLogic.sWinner + " zostaje zwycięzcą!");
          displayStick(GameLogic.sSet);
          disableAll();
      } else if (mStatusCounter == 9) {
          mDisplay.setText("REMIS. Spróbuj ponownie ;)");
      }
  }
  
  private void displayStick(int stick) {
      View view;
      switch (stick) {
          case 1:
              view = findViewById(R.id.top_horizontal);
              break;
          case 2:
              view = findViewById(R.id.center_horizontal);
              break;
          case 3:
              view = findViewById(R.id.bottom_horizontal);
              break;
          case 4:
              view = findViewById(R.id.left_vertical);
              break;
          case 5:
              view = findViewById(R.id.center_vertical);
              break;
          case 6:
              view = findViewById(R.id.right_vertical);
              break;
          case 7:
              view = findViewById(R.id.left_right_diagonal);
              break;
          case 8:
              view = findViewById(R.id.right_left_diagonal);
              break;
          default://which will never happen
              view = findViewById(R.id.top_horizontal);
      }
      view.setVisibility(View.VISIBLE);
  }
  
  private void disableAll() {
      for (int i = 0; i &lt; 9; i++)
          mBlocks[i].setEnabled(false);
  }
  
  @Override
  public void onBackPressed() {
  
  }
  
  private void showResults() {
      if (GameLogic.mWinner == GameLogic.CIRCLE) {
  
      } else if (GameLogic.mWinner == GameLogic.CROSS) {
  
      } else {
  
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <pre><code>package com.example.jkaminski.myapplication;
  
  import android.widget.ImageView;
  
  public class GameLogic {
  
  private static ImageView[] sBlocks;
  public static String sWinner;
  public static int sSet;
  
  public static final int CIRCLE = 0;
  public static final int CROSS = 1;
  
  public static int mWinner;
  
  
  private static boolean areSameInSet(int first, int second, int third, int set) {
      boolean value = sBlocks[first - 1].getId() == sBlocks[second - 1].getId() &amp;&amp; sBlocks[second - 1].getId() == sBlocks[third - 1].getId();
      if (value) {
          if (sBlocks[first - 1].getId() == CIRCLE) {
              mWinner = CIRCLE;
              sWinner = "KÓŁKO";
          } else {
              mWinner = CROSS;
              sWinner = "KRZYŻYK";
          }
          sSet = set;
      }
      return value;
  }
  
  
  public static boolean isCompleted(int position, ImageView[] blocks) {
      GameLogic.sBlocks = blocks;
      boolean isComplete = false;
      switch (position) {
          case 1:
              isComplete = areSameInSet(1, 2, 3, 1) ||
                      areSameInSet(1, 4, 7, 4) ||
                      areSameInSet(1, 5, 9, 7);
              break;
          case 2:
              isComplete = areSameInSet(1, 2, 3, 1) ||
                      areSameInSet(2, 5, 8, 5);
              break;
          case 3:
              isComplete = areSameInSet(1, 2, 3, 1) ||
                      areSameInSet(3, 6, 9, 6) ||
                      areSameInSet(3, 5, 7, 8);
              break;
          case 4:
              isComplete = areSameInSet(4, 5, 6, 2) ||
                      areSameInSet(1, 4, 7, 4);
              break;
          case 5:
              isComplete = areSameInSet(4, 5, 6, 2) ||
                      areSameInSet(2, 5, 8, 5) ||
                      areSameInSet(1, 5, 9, 7) ||
                      areSameInSet(3, 5, 7, 8);
              break;
          case 6:
              isComplete = areSameInSet(4, 5, 6, 2) ||
                      areSameInSet(3, 6, 9, 6);
              break;
          case 7:
              isComplete = areSameInSet(7, 8, 9, 3) ||
                      areSameInSet(1, 4, 7, 4) ||
                      areSameInSet(3, 5, 7, 8);
              break;
          case 8:
              isComplete = areSameInSet(7, 8, 9, 3) ||
                      areSameInSet(2, 5, 8, 5);
              break;
          case 9:
              isComplete = areSameInSet(7, 8, 9, 3) ||
                      areSameInSet(3, 6, 9, 6) ||
                      areSameInSet(1, 5, 9, 7);
              break;
      }
      return isComplete;
  }
  </code></pre>
  
  <p>}</p>