代码改变世界
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);