开发者

AlertDialog Android HELP

I have one countdown timer, and I want onFinish to pop up yes/no message box, and do something with it, but I get this error: The constructor AlertDialog.Builder(new CountDownTimer(){}) is undefined.

CountDownTimer start1 = null;
start1 = new CountDownTimer(60000, 1000) {

  public void onTick(long millisUntilFinished) {
    tvPreostaloVrijeme.setText(Integer
                               .toString((int) (millisUntilFinished / 1000)));
  }

  public void onFinish() {
    broj1.setText("");
    broj2.setText("");
    op.setText("");
    posalji.setEnabled(false);

    AlertDialog.Builder builder = new AlertDialog.Builder(this);
    builder.setMessage("Are you sure?").setPositiveButton("Yes", dialogClickListener)
    .setNegativeButton("No", dialogClickListener).show();

  }
} .start();

DialogInterface.OnClickListener dialogClickListener = new DialogInterface.OnClickListener() {
  @Override
  public void onClick(DialogInterface dialog, int which) {
    switch (which) {
    case DialogInterface.BUTTON_POSITIVE:
      //Yes button clicked
      break;

    case DialogInterface.BUTTON_NEGATIVE:
      //No butto开发者_如何学Gon clicked
      break;
    }
  }
};


AlertDialog.Builder builder = new AlertDialog.Builder(this);

remove this with getApplicationContext()

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜