@Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); tvScore = (TextView) findViewById(R.id.tvScore); tvBest = (TextView) findViewById(R.id.tvBest); tvBest.setText(ScoreMaster.readScore(this) + ""); gameView = (GameView) findViewById(R.id.gameView); btnNewGame = (Button) findViewById(R.id.btn_new_game); btnNewGame.setOnClickListener( new View.OnClickListener() { @Override public void onClick(View v) { gameView.startGame(); } }); }
public void showScore() { tvScore.setText(score + ""); tvBest.setText(ScoreMaster.readScore(this) + ""); }
/** Clear score. Before it, check whether it's the best score. */ public void clearScore() { ScoreMaster.saveScore(this, score); score = 0; showScore(); }