public class MoleActivity extends Activity { 

private Handler mHandler = null; // 메시지를 전달할 핸들러

int mScore = 0; // 점수

int mTime = 30; // 제한시간

int[] imgValue = new int[9]; 

ImageButton[] imgMole = new ImageButton[9]; // 두더지 새끼들

    @Override 

    public void onCreate(Bundle savedInstanceState) { //액티비티가 실행되면 onCreate 실행됨

        super.onCreate(savedInstanceState); // 부모 클래스의 onCreate 실행됨

        setContentView(R.layout.main); //액티비티의 콘텐츠뷰(레이아웃)을 main으로 설정

        

Button btnReset = (Button)findViewById(R.id.btnReset); // findViewById 말 그대로 아이디로 객체를 찾음. (button)형식으로 반환

final TextView  txtScore = (TextView)findViewById(R.id.txtScore); //점수를 보여줄 텍스트 뷰   

final TextView  txtTime = (TextView)findViewById(R.id.txtTime);     // 시간을 보여줄 텍스트뷰

imgMole[0] = (ImageButton)findViewById(R.id.imageButton1); // 두더지새끼들도 findviewbyid로 찾아놓음

imgMole[1] = (ImageButton)findViewById(R.id.imageButton2);

imgMole[2] = (ImageButton)findViewById(R.id.imageButton3);

imgMole[3] = (ImageButton)findViewById(R.id.imageButton4);

imgMole[4] = (ImageButton)findViewById(R.id.imageButton5);

imgMole[5] = (ImageButton)findViewById(R.id.imageButton6);

imgMole[6] = (ImageButton)findViewById(R.id.imageButton7);

imgMole[7] = (ImageButton)findViewById(R.id.imageButton8);

imgMole[8] = (ImageButton)findViewById(R.id.imageButton9);

btnReset.setOnClickListener(new View.OnClickListener(){ // 리셋 버튼에 온클릭리스너 만듬 (미친새끼 이걸 왜 이렇게 하냐)

        public void onClick(View v){

         mScore = 0;

         mTime = 30;

         mHandler.sendEmptyMessageDelayed(0, 1000); //클릭하면 빈 메시지 보냄

        }

    }); //온클릭리스너 끝

for(int i=0; i<9; i++){

final int arrayI = i;

imgMole[i].setOnClickListener(new View.OnClickListener(){ //두더지 새끼들도 온클릭 리스너 박음

        public void onClick(View v){ //클릭하면

         imgMole[arrayI].setImageResource(R.drawable.none); // 이미지를 바꾸고

         if(imgValue[arrayI] == 1){ // 두더지 새끼가 나온 상태면...

         mScore++; //점수 추가하고

         imgValue[arrayI] =0; //

         } //온클릭 끝

        

        } //온클릭리스너 생성자 함수 재정의

    });         //  imgMole[i].setOnClickListener 끝

} // for문 끝

        mHandler = new Handler() { // 메시지 받는 핸들러

         public void handleMessage(Message msg) {

        

         txtTime.setText("시간:" + mTime); //시간이랑 점수 텍스트뷰 내용 바꿈 바꿈 (invalidate인가? 갱신 해줘야 뜬다. 병신아.)

         txtScore.setText("점수:" + mScore);

         if(mTime== 0){

     Toast toast = Toast.makeText(getBaseContext(), 

     "종료", 100000);

     toast.show();          //토스트 띄움

         return;

         }         // if(mTime== 0) 끝

         mHandler.sendEmptyMessageDelayed(0, 1000); // 1초마다 핸들러 쏴줌. 미친 새끼 쓰레드는 어따 팔아치웠냐

         mTime--; // 1초 감소

         double rValue = java.lang.Math.random(); 

         int selectedIndex = (int)(rValue * 10);

         if(selectedIndex == 9)

         selectedIndex = 4;

         for(int i=0; i<9;i++){ // 두더지 새끼들 

         imgValue[i] = 0; 

         imgMole[i].setImageResource(R.drawable.none); // 다 땅속에 박음

         } // for문 종료

         imgValue[selectedIndex] = 1; 

         imgMole[selectedIndex].setImageResource(R.drawable.mole);

         } // public void handleMessage(Message msg) 끝

        };        // 핸들러 선언 끝

    } // onCreate 끝

} // MoleActivity 끝





내가 교수면 이거 찢어버린다.