package franck.pingpong; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; import android.widget.TextView; /** * The controller of the Ping Pong app. * * @author Franck van Breugel */ public class PingPongActivity extends AppCompatActivity { private PingPongModel model; /** * Initializes this controller. * * @param savedInstanceState information needed for re-initialization. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_ping_pong); this.model = new PingPongModel(); } /** * Sets the text to either Ping or Pong. * * @param view not applicable. */ public void buttonClicked(View view) { // get the text from the model String text = this.model.getPingOrPong(); // set the text View textView = findViewById(R.id.text); TextView answerText = (TextView) textView; answerText.setText(text); } }