Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.example.myxogame;
- import androidx.appcompat.app.AppCompatActivity;
- import android.content.Intent;
- import android.os.Bundle;
- import android.view.View;
- import android.widget.SeekBar;
- import android.widget.TextView;
- public class MainActivity extends AppCompatActivity {
- TextView tvRows, tvCols;
- SeekBar skbRows, skbCols;
- int rows, cols;
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_main);
- tvRows = findViewById(R.id.tvRows);
- skbRows = findViewById(R.id.skbRows);
- tvCols = findViewById(R.id.tvCols);
- skbCols = findViewById(R.id.skbCols);
- rows = 4;
- skbRows.setProgress(rows);
- tvRows.setText("Rows = " + rows);
- cols = 4;
- skbCols.setProgress(cols);
- tvCols.setText("Cols = " + cols);
- skbRows.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- tvRows.setText("Rows = " + progress);
- rows = progress;
- }
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
- });
- skbCols.setOnSeekBarChangeListener(new SeekBar.OnSeekBarChangeListener() {
- @Override
- public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
- tvCols.setText("Cols = " + progress);
- cols = progress;
- }
- @Override
- public void onStartTrackingTouch(SeekBar seekBar) {
- }
- @Override
- public void onStopTrackingTouch(SeekBar seekBar) {
- }
- });
- }
- public void startGame(View view) {
- int winCount = 0;
- switch (view.getId()) {
- case R.id.btnEasy:
- winCount = 3;
- break;
- case R.id.btnMedium:
- winCount = 4;
- break;
- case R.id.btnHard:
- winCount = 5;
- break;
- }
- if (winCount > 0) {
- Intent intent = new Intent(this, GameActivity.class);
- intent.putExtra("ROWS_COUNT", rows);
- intent.putExtra("COLS_COUNT", cols);
- intent.putExtra("WIN_COUNT", winCount);
- startActivity(intent);
- }
- }
- }
Add Comment
Please, Sign In to add comment