package eecs1022.midtermb; import android.support.v7.app.AppCompatActivity; import android.os.Bundle; import android.view.View; /** * The controller of the app. * * @author Franck van Breugel */ public class MainActivity extends AppCompatActivity { private Toggle toggle; /** * Initializes this controller. * * @param savedInstanceState information needed for re-initialization. */ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); this.setContentView(R.layout.activity_main); this.toggle = new Toggle(); } /** * Toggles the text and color of the button. * * @param view not applicable. */ public void pressed(View view) { // get the button View buttonView = findViewById(R.id.button); Button button = (Button) buttonView; // toggle this.toggle.it(); // set text String text = this.toggle.getText(); button.setText(text); // set colour int color = this.toggle.getColor(); button.setBackgroundColor(color); } }