Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package wks.android;
- import java.util.Arrays;
- import android.app.Activity;
- import android.content.Intent;
- import android.content.pm.ActivityInfo;
- import android.os.Bundle;
- import android.util.Log;
- import android.view.View;
- import android.view.Window;
- import android.view.WindowManager;
- import android.view.View.OnClickListener;
- import android.widget.Button;
- import android.widget.ImageView;
- import android.widget.TextView;
- public class GameFindActivity extends Activity {
- private int total=7;
- private Button[] number_btn = {null,null,null,null,null,null,null};
- private int[] btn = {R.id.button1,R.id.button2,R.id.button3,R.id.button4,
- R.id.button5,R.id.button6,R.id.button7};
- private ImageView[] iv = {null,null,null,null,null,null,null};
- private TextView tv1;
- /** Called when the activity is first created. */
- public void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- requestWindowFeature(Window.FEATURE_NO_TITLE);
- getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FULLSCREEN);
- setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
- setContentView(R.layout.gamefind);
- tv1 = (TextView)findViewById( R.id.textView1 );
- number_btn [0] = (Button)findViewById( R.id.button1 );
- number_btn [1] = (Button)findViewById( R.id.button2 );
- number_btn [2] = (Button)findViewById( R.id.button3 );
- number_btn [3] = (Button)findViewById( R.id.button4 );
- number_btn [4] = (Button)findViewById( R.id.button5 );
- number_btn [5] = (Button)findViewById( R.id.button6 );
- number_btn [6] = (Button)findViewById( R.id.button7 );
- iv [0] = (ImageView)findViewById( R.id.imageView1 );
- iv [1] = (ImageView)findViewById( R.id.imageView2 );
- iv [2] = (ImageView)findViewById( R.id.imageView3 );
- iv [3] = (ImageView)findViewById( R.id.imageView4 );
- iv [4] = (ImageView)findViewById( R.id.imageView5 );
- iv [5] = (ImageView)findViewById( R.id.imageView6 );
- iv [6] = (ImageView)findViewById( R.id.imageView7 );
- for(int i = 0 ; i < number_btn.length ; i ++ )
- {
- number_btn[i].setOnClickListener( number_event ) ;
- }
- }
- private OnClickListener number_event = new OnClickListener()
- {
- public void onClick( View v )
- {
- total--;
- tv1.setText("目前剩" + String.valueOf(total) + "個");
- iv[Arrays.binarySearch(btn, v.getId())].setVisibility(View.VISIBLE);
- ((Button)v).layout(0, 0, 0, 0);
- if(total == 0)
- {
- tv1.setText("已全找到:D");
- Intent intent = new Intent() ;
- intent.setClass(GameFindActivity.this, GameFind2Activity.class) ;
- startActivity(intent) ;
- }
- }
- };
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement