2012-01-12 32 views
0

5秒後にダイアログボックスがポップアップします。誰かが私が間違っていることを私に説明することはできますか?イムは、私だけので、私の愚か容赦下さい今、約3ヶ月間programmmingてきた(、タイマーの終了()の項でエラーを取得基本的なアンドロイドタイマー?

public void run() { 
    CountDownTimer counter = new CountDownTimer(5000,1000) { 

     @Override 
     public void onTick(long millisUntilFinished) { 
      // TODO Auto-generated method stub 

     } 
     public void onFinish() { 
      if (count == value) { 
       AlertDialog.Builder lost = new AlertDialog.Builder(this); // <-----There is my error its telling me // to go and set up my dialog AlertDialog.Builder(new CountDownTimer(){}) { And I dont understand it 


       lost.setMessage("You lost! you are ugly!" + 
         "" + 
       " new game?"); 
       lost.setCancelable(false); 
       lost.setPositiveButton("Yes", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int id) { 
         clicks.setText("Clicks "); 
         count = 1; 
         generator = new Random(); 
         value = generator.nextInt(100); 
         imgBtn.setImageResource(R.drawable.push); 
        } 
       }); 
       lost.setNegativeButton("No", new DialogInterface.OnClickListener() { 
        public void onClick(DialogInterface dialog, int id) { 
         generator = new Random(); 
         value = generator.nextInt(100); 
         ButtonMasherActivity.this.finish(); 
        } 
       }); 

       lost.create(); 
       lost.show(); 
      } 
     } 

    }; 
    counter.start(); 
} 
+0

あなたはショーのログを提供してくださいましたエラーはどのようなタイプ... –

答えて

1

これ試してみてください:。

AlertDialog.Builder lost = new AlertDialog.Builder(ButtonMasherActivity.this); 

Context目的ではないCountdownTimerオブジェクトをAlertDialog.Builder必要があります。

+0

[OK]をので、私は完全にカウントダウンタイマー? –

+0

を取り除くことができますちょうどあなたがグラムされている行を置き換えます私の答えで私が提供したラインでエラーを出すと、あなたは良いことになるはずです。 –

+0

@Richあなたの問題を解決しましたか? –