我希望AlertDialog在CountDownTimer完成后显示,但在尝试执行操作时出现错误。有没有人有解决方案或更好的方法?Android CountDownTimer和AlertDialog
{
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();
}
也让我们知道什么错误你越来越..这里发布你的logcat – 5hssba 2012-03-14 06:01:08
什么是错误? – 2012-03-14 06:01:20
将此代码发布到单独的mehtod中: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(); 比完成后调用该方法,我希望这会起作用 – 2012-03-14 06:37:41