Plaster

java
package com.example.josh.tictactoe; import android.app.Activity; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.Button; import android.widget.TextView; public class MainActivity extends AppCompatActivity implements View.OnClickListener { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); public String team = "X"; public void swapTeam() {//changing public variables eeeeewy if (team.equals("X")) team = "0"; else team = "X"; } Button b1 = (Button) findViewById(R.id.b1); Button b2 = (Button) findViewById(R.id.b2); Button b3 = (Button) findViewById(R.id.b3); Button b4 = (Button) findViewById(R.id.b4); Button b5 = (Button) findViewById(R.id.b5); Button b6 = (Button) findViewById(R.id.b6); Button b7 = (Button) findViewById(R.id.b7); Button b8 = (Button) findViewById(R.id.b8); Button b9 = (Button) findViewById(R.id.b9); TextView tTeam = (TextView) findViewById(R.id.tTeam); final Button[] buttons = {b1, b2, b3, b4, b5, b6, b7, b8, b9}; for (int i = 0; i < 9; i++) { buttons[i].setOnClickListener(this); } @Override public void onClick (View arg0){ if (Button.getText().equals(" ")) { Button.setText(team); swapTeam(); } } } }