Android Open Source - noughts-and-crosses-android Menu Activity






From Project

Back to project page noughts-and-crosses-android.

License

The source code is released under:

MIT License

If you think the Android project noughts-and-crosses-android listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.JamesWhite.NoughtsAndCrosses;
/* ww  w.j a  v  a 2  s. c  o m*/
/**
 * MenuActivity Handles showing the games main menu and switching to other activites
 * 
 * @author James White
 */

import android.app.Activity;
import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class MenuActivity extends Activity {
  
  Button newGame;
  Button localHighScores;
  Button globalHighScores;
  TextView text;
  TextView title;
  
  // Define our external font used in the game
  Typeface alphaMack;
  
    @Override
    public void onCreate(Bundle savedInstanceState) {
      
        super.onCreate(savedInstanceState);
        setContentView(R.layout.menu);
        
        // Define our buttons and title
        newGame = (Button) findViewById(R.id.newGameButton);
        localHighScores = (Button) findViewById(R.id.newLocalHighScores);
        globalHighScores = (Button) findViewById(R.id.newGlobalHighScores);
        title = (TextView) findViewById(R.id.title);
        
        // set up our custom typeface
        alphaMack = Typeface.createFromAsset(getApplicationContext().getAssets(),"fonts/alphamack.ttf");
        title.setTypeface(alphaMack);
        
        // Switch to the game activity
        newGame.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {

        Intent gameIntent = new Intent(MenuActivity.this, GameActivity.class);
        startActivity(gameIntent);
        
      }
          
        });
        
        // Switch to the local high scores activity
        localHighScores.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        
        Intent localHighScoreIntent = new Intent(MenuActivity.this, LocalHighScoreActivity.class);
        startActivity(localHighScoreIntent);
        
      }
          
        });
        
        // Switch to the global high scores activity
        globalHighScores.setOnClickListener(new View.OnClickListener() {

      @Override
      public void onClick(View v) {
        
        Intent loadingGlobalHighScoreIntent = new Intent(MenuActivity.this, LoadingGloabalHighScoresActivity.class);
        startActivity(loadingGlobalHighScoreIntent);
        
      }
          
        });
        
    }
    
}




Java Source Code List

com.JamesWhite.NoughtsAndCrosses.AsyncSubmitGloabalHighScoresActivity.java
com.JamesWhite.NoughtsAndCrosses.ComputerPlayer.java
com.JamesWhite.NoughtsAndCrosses.Database.java
com.JamesWhite.NoughtsAndCrosses.GameActivity.java
com.JamesWhite.NoughtsAndCrosses.Game.java
com.JamesWhite.NoughtsAndCrosses.GlobalHighScoreActivity.java
com.JamesWhite.NoughtsAndCrosses.LoadingGloabalHighScoresActivity.java
com.JamesWhite.NoughtsAndCrosses.LocalDatabase.java
com.JamesWhite.NoughtsAndCrosses.LocalHighScoreActivity.java
com.JamesWhite.NoughtsAndCrosses.MenuActivity.java
com.JamesWhite.NoughtsAndCrosses.Player.java
com.JamesWhite.NoughtsAndCrosses.RemoteDatabase.java