Activator.java :  » UnTagged » android-development-samples » cha » app » pong » Android Open Source

Android Open Source » UnTagged » android development samples 
android development samples » cha » app » pong » Activator.java
package cha.app.pong;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;

public class Activator extends Activity implements OnClickListener{
  private final static String TAG = "Activator";
  private Button btn_easy, btn_normal, btn_hard;
  private GameContainer game_screen;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
      super.onCreate(savedInstanceState);
      setContentView(R.layout.main);
   
      btn_easy = (Button)findViewById(R.id.easy_mode);
      btn_normal = (Button)findViewById(R.id.normal_mode);
      btn_hard = (Button)findViewById(R.id.hard_mode);
     
      btn_easy.setOnClickListener(this);
      btn_normal.setOnClickListener(this);
      btn_hard.setOnClickListener(this);
      Log.d(TAG, "Pong Loaded");
    }

    public void onDestroy(){
      super.onDestroy();
    }
    
    @Override
    public void onClick( View v ) {
      Intent game_screen = new Intent(getApplicationContext(), GameContainer.class);
      
      if(v.equals(btn_easy))
        game_screen.putExtra( "difficulty", Utilities.EASY_MODE );
      else if(v.equals(btn_normal))
        game_screen.putExtra( "difficulty", Utilities.NORM_MODE );
      else if(v.equals(btn_hard))
        game_screen.putExtra( "difficulty", Utilities.HARD_MODE );

      startActivity(game_screen);
    }
}
java2s.com  | Contact Us | Privacy Policy
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.