package sysu.androidclub.campusrichman;
import java.util.ArrayList;
import java.util.List;
import java.util.Timer;
import java.util.TimerTask;
import android.R.string;
import android.app.Activity;
import android.app.AlertDialog;
import android.app.Dialog;
import android.content.DialogInterface;
import android.content.Intent;
import android.database.DataSetObserver;
import android.graphics.Color;
import android.graphics.drawable.AnimationDrawable;
import android.os.Bundle;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.view.ViewTreeObserver.OnPreDrawListener;
import android.view.animation.AlphaAnimation;
import android.view.animation.Animation;
import android.view.animation.AnimationSet;
import android.view.animation.RotateAnimation;
import android.view.animation.ScaleAnimation;
import android.widget.ArrayAdapter;
import android.widget.BaseAdapter;
import android.widget.Gallery;
import android.widget.ImageButton;
import android.widget.ImageView;
import android.widget.ScrollView;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;
import android.widget.AbsoluteLayout.LayoutParams;
import android.widget.ImageView.ScaleType;
/**.
* .
* @author ,
* @version 0.0.1 2010-8-22
*/
public class PlayerSelectionScene extends Activity{
/** Called when the activity is first created. */
ImageView mReturn,mGameBegin;
Gallery mPlayerSelectGallery;
int mButtonNumber=3;
List<String> mSchoolList;
List<String> mTurnList;
ArrayAdapter<String> mSchoolAdapter;
ArrayAdapter<String> mTurnAdapter;
Spinner mSchoolSpinner;
Spinner mTurnSpinner;
/**.
* .
* @author
* @version 0.0.1 2010-8-22
*/
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.playerselectionscene);
mReturn=(ImageView)findViewById(R.id.returnbutton);
mReturn.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(PlayerSelectionScene.this,GameModeSelectionScene.class);
startActivity(intent);
PlayerSelectionScene.this.finish();
}
});
mPlayerSelectGallery=(Gallery)findViewById(R.id.playerselectgallery);
mPlayerSelectGallery.setAdapter(new BaseAdapter() {
int[] mPlayerImageSourceIds={R.drawable.boy01,R.drawable.boy02,R.drawable.girl01,R.drawable.girl02};
public View getView(int position, View convertView, ViewGroup parent) {
// TODO Auto-generated method stub
ImageView imageView=new ImageView(PlayerSelectionScene.this);
imageView.setImageResource(mPlayerImageSourceIds[position]);
imageView.setLayoutParams(new Gallery.LayoutParams(Gallery.LayoutParams.FILL_PARENT,Gallery.LayoutParams.FILL_PARENT));
imageView.setScaleType(ScaleType.FIT_XY);
return imageView;
}
public long getItemId(int position) {
// TODO Auto-generated method stub
return position;
}
public Object getItem(int position) {
// TODO Auto-generated method stub
return position;
}
public int getCount() {
// TODO Auto-generated method stub
return mPlayerImageSourceIds.length;
}
});
mSchoolList=new ArrayList<String>();
mSchoolList.add("");
mSchoolAdapter=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mSchoolList);
mSchoolSpinner=(Spinner)findViewById(R.id.schoolselection);
mSchoolSpinner.setAdapter(mSchoolAdapter);
mTurnList=new ArrayList<String>();
mTurnList.add("30");
mTurnAdapter=new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, mTurnList);
mTurnSpinner=(Spinner)findViewById(R.id.turnselection);
mTurnSpinner.setAdapter(mTurnAdapter);
mGameBegin=(ImageView)findViewById(R.id.gamebeginbutton);
mGameBegin.setOnClickListener(new View.OnClickListener(){
public void onClick(View v) {
Intent intent=new Intent();
intent.setClass(PlayerSelectionScene.this,CampusRichMan.class);
Bundle bundle=new Bundle();
bundle.putInt("PlayerSelection", mPlayerSelectGallery.getSelectedItemPosition());
bundle.putInt("TurnSelection", mTurnSpinner.getSelectedItemPosition());
bundle.putInt("SchoolSelection", mSchoolSpinner.getSelectedItemPosition());
intent.putExtras(bundle);
startActivity(intent);
PlayerSelectionScene.this.finish();
}
});
}
}
|