Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.uml.youmath;
- import android.app.Activity;
- import android.content.Intent;
- import android.content.SharedPreferences;
- import android.os.Bundle;
- import android.preference.PreferenceManager;
- import android.view.View;
- import android.view.View.OnClickListener;
- import android.view.Window;
- import android.widget.ImageButton;
- import android.widget.TextView;
- /**
- * This class is the Activity that takes care of the Game Type selection
- * screen/view. The Game Type we are defining as the choice of math questions to
- * be served up (addition, multiplication, etc)
- *
- * @author cdietsch
- */
- public class GameTypeSelect extends Activity implements OnClickListener {
- ImageButton btn_addition, btn_subtraction;
- ImageButton btn_multiplication, btn_division, btn_identity;
- int gameType = 0, currentPos = 0;
- TextView gameTypeText, playerNameText;
- @Override
- public void onClick(View v) {
- if (v == btn_addition) {
- // Send addition choice along to stage select
- gameType = ProblemMaker.ADDITION;
- }
- if (v == btn_subtraction) {
- gameType = ProblemMaker.SUBTRACTION;
- }
- if (v == btn_multiplication) {
- gameType = ProblemMaker.MULTIPLICATION;
- }
- if (v == btn_division) {
- gameType = ProblemMaker.DIVISION;
- }
- if (v == btn_identity) {
- gameType = ProblemMaker.NUMBER_IDENTITY;
- }
- Intent i = new Intent(GameTypeSelect.this, StageSelection.class);
- i.putExtra("gametype", gameType);
- startActivity(i);
- }
- @Override
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- this.requestWindowFeature(Window.FEATURE_NO_TITLE);
- setContentView(R.layout.gametypeselect);
- // Find the playerNameText view, grab the Shared Preferences and grab
- // the username
- // to populate this text field.
- playerNameText = (TextView) findViewById(R.id.playerNameText);
- SharedPreferences prefs = PreferenceManager
- .getDefaultSharedPreferences(this);
- String username = prefs.getString(getResources().getString(
- R.string.username_pref), getResources().getString(
- R.string.username_pref_default));
- playerNameText.setText(username);
- btn_addition = (ImageButton) findViewById(R.id.btn_addition);
- btn_subtraction = (ImageButton) findViewById(R.id.btn_subtraction);
- btn_multiplication = (ImageButton) findViewById(R.id.btn_multiplication);
- btn_division = (ImageButton) findViewById(R.id.btn_division);
- btn_identity = (ImageButton) findViewById(R.id.btn_identity);
- btn_addition.setOnClickListener(this);
- btn_subtraction.setOnClickListener(this);
- btn_multiplication.setOnClickListener(this);
- btn_division.setOnClickListener(this);
- btn_identity.setOnClickListener(this);
- }
- @Override
- public void onPause() {
- currentPos = SoundService.musicPlayer.getCurrentPosition();
- SoundService.currentPos = currentPos;
- SoundService.musicPlayer.pause();
- super.onPause();
- }
- @Override
- public void onResume() {
- SoundService.resumeAt();
- super.onResume();
- }
- }
Add Comment
Please, Sign In to add comment