1

我希望 AlertDialog 在 CountDownTimer 完成后显示,但是当我尝试执行此操作时出现错误。有没有人有解决方案或更好的方法?

{
new CountDownTimer(60000, 1000) {

 public void onTick(long millisUntilFinished) {
 mTextField.setText(":" + millisUntilFinished / 1000);
 }
 public void onFinish() {
 mTextField.setText("GAME OVER");
 mTextField.setTextSize(50);

     AlertDialog.Builder ADB = new AlertDialog.Builder(getApplicationContext());
     ADB.setTitle("GAME OVER")
        .setMessage(R.string.app_name)
        .setNeutralButton("PRESS BACK AND START GAME TO PLAY AGAIN", null)
        .show();
 }
    }.start();
}
4

2 回答 2

3

实际上你的代码完美我运行它但替换

 AlertDialog.Builder ADB = new AlertDialog.Builder(getApplicationContext());

通过 where 将 Game 替换为您的活动名称

 AlertDialog.Builder ADB = new AlertDialog.Builder(Game.this);
于 2012-03-14T06:09:49.157 回答
1

试试这个代码

 new Thread()
   {
       public void run()
       {
            sleep(3000);
           AlertDialog.Builder successfullyLogin = new Builder(LWM.this);
            successfullyLogin.setCancelable(false);
           successfullyLogin.setMessage("Successfully Login !").show();
           }
   };
于 2012-03-14T06:19:48.717 回答