I have a problem when it comes to create a high score view. The point of the game is to click as many times as you can on a button in 15 seconds and I would like to make appear a high score in the right corner for instance. Here is my code:
public class newgame extends Activity {
int clicks = 0;
TextView textCount;
Button buttonCount;
int guessCount =0;
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_newgame);
final int oldscore = getSharedPreferences("myPrefs", MODE_PRIVATE).getInt("highscore", 0);
final TextView textView = (TextView) findViewById(R.id.applesEaten);
buttonCount = (Button) findViewById(R.id.button);
buttonCount.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
clicks++;
textView.setText("Clicks: " + clicks);
TextView textView = (TextView)findViewById(R.id.topScoreView);
textView.setText("Best: " + oldscore);
}
});
final TextView textic = (TextView) findViewById(R.id.textView2);
CountDownTimer Count = new CountDownTimer(15000, 1000) {
public void onTick(long millisUntilFinished) {
int seconds = (int) ((millisUntilFinished / 1000));
textic.setText("Time Left: " + millisUntilFinished / 1000);
}
public void onFinish() {
textic.setText("Time's Up!");
buttonCount.setEnabled(false);
if (clicks > oldscore)
getSharedPreferences("myPrefs", MODE_PRIVATE).edit().putInt("highscore", clicks).commit();
}
};
Count.start();
}
How would I go proceed to achieve this?