开发者

android how to show a dialog for a specific time

I would like to show an alert dialog that shows a counter(timer of time) and after 10 seconds will automatically disappear.

I have:

builder = new AlertDialog.Builder(this);
    builder.setTitle(title);
    builder.setMessage(msg);
    final EditText input = new EditText(this);
    builder.setView(input);
    runOnUiThread(new Runnable() {
        @Ove开发者_如何学Pythonrride
        public void run() {
            builder.setMessage("ELEOS");
        }
    });
    builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            dismissDialog(id);
        }
    });
    return builder.create();

which simply creates the dialog.


There is a class android.os.CountDownTimer just for this. Create one and in the onFinish() dismiss your dialog.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜