Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.youdothemath;
- import androidx.appcompat.app.AppCompatActivity;
- import android.content.Intent;
- import android.content.SharedPreferences;
- import android.os.Bundle;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.TextView;
- public class MainActivity extends AppCompatActivity implements OnClickListener {
- private Button MathButton;
- private Button MazeButton;
- private TextView WelcomeText;
- private TextView Result1Text;
- private TextView Result2Text;
- private TextView MathText;
- private TextView MazeText;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- MathButton = findViewById(R.id.math_icon);
- MazeButton = findViewById(R.id.maze_icon);
- WelcomeText = findViewById(R.id.welcome);
- Result1Text = findViewById(R.id.result1);
- Result2Text = findViewById(R.id.result2);
- MathText = findViewById(R.id.math_txt);
- MazeText = findViewById(R.id.maze_txt);
- MathButton.setOnClickListener(this);
- SharedPreferences scorePrefs = getSharedPreferences(PlayGame.GAME_PREFS, 0);
- String[] savedScores = scorePrefs.getString("highScores", "").split("\\|");
- String BestScore = savedScores[0];
- Result1Text.setText(BestScore);
- }
- public void onClick(View view) {
- if (view.getId() == R.id.math_icon) {
- Intent intent = new Intent(this, Menu.class);
- startActivity(intent);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement