Android几秒后自动关闭dialog
Posted 东北老十七
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Android几秒后自动关闭dialog相关的知识,希望对你有一定的参考价值。
代码改变世界
Android几秒后自动关闭dialog
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext()); builder.setTitle("发送成功!"); builder.setMessage("2秒后自动关闭!"); builder.setCancelable(true); final AlertDialog dlg = builder.create(); dlg.show(); final Timer t = new Timer(); t.schedule(new TimerTask() { public void run() { Intent intent1 = new Intent(); intent1.setClass(InquirySheetListActivity.this, MainActivity.class); startActivity(intent1); finish(); dlg.dismiss(); t.cancel(); } }, 2000);
AlertDialog.Builder builder = new AlertDialog.Builder(v.getContext());
builder.setTitle("发送成功!");
builder.setMessage("2秒后自动关闭!");
builder.setCancelable(true);
final AlertDialog dlg = builder.create();
dlg.show();
final Timer t = new Timer();
t.schedule(new TimerTask() {
public void run() {
Intent intent1 = new Intent();
intent1.setClass(InquirySheetListActivity.this, MainActivity.class);
startActivity(intent1);
finish();
dlg.dismiss();
t.cancel();
}
}, 2000);
以上是关于Android几秒后自动关闭dialog的主要内容,如果未能解决你的问题,请参考以下文章