• <tfoot id='BgmHA'></tfoot>

    <small id='BgmHA'></small><noframes id='BgmHA'>

  • <legend id='BgmHA'><style id='BgmHA'><dir id='BgmHA'><q id='BgmHA'></q></dir></style></legend>

    <i id='BgmHA'><tr id='BgmHA'><dt id='BgmHA'><q id='BgmHA'><span id='BgmHA'><b id='BgmHA'><form id='BgmHA'><ins id='BgmHA'></ins><ul id='BgmHA'></ul><sub id='BgmHA'></sub></form><legend id='BgmHA'></legend><bdo id='BgmHA'><pre id='BgmHA'><center id='BgmHA'></center></pre></bdo></b><th id='BgmHA'></th></span></q></dt></tr></i><div id='BgmHA'><tfoot id='BgmHA'></tfoot><dl id='BgmHA'><fieldset id='BgmHA'></fieldset></dl></div>
        <bdo id='BgmHA'></bdo><ul id='BgmHA'></ul>

        5秒后Android关闭对话框?

        时间:2023-09-29
          <bdo id='kFV6q'></bdo><ul id='kFV6q'></ul>

          1. <small id='kFV6q'></small><noframes id='kFV6q'>

          2. <i id='kFV6q'><tr id='kFV6q'><dt id='kFV6q'><q id='kFV6q'><span id='kFV6q'><b id='kFV6q'><form id='kFV6q'><ins id='kFV6q'></ins><ul id='kFV6q'></ul><sub id='kFV6q'></sub></form><legend id='kFV6q'></legend><bdo id='kFV6q'><pre id='kFV6q'><center id='kFV6q'></center></pre></bdo></b><th id='kFV6q'></th></span></q></dt></tr></i><div id='kFV6q'><tfoot id='kFV6q'></tfoot><dl id='kFV6q'><fieldset id='kFV6q'></fieldset></dl></div>

                  <tfoot id='kFV6q'></tfoot>
                  <legend id='kFV6q'><style id='kFV6q'><dir id='kFV6q'><q id='kFV6q'></q></dir></style></legend>
                    <tbody id='kFV6q'></tbody>
                  本文介绍了5秒后Android关闭对话框?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在开发一个无障碍应用.当用户想离开应用程序时,我会显示一个对话框,他必须在其中确认他想离开,如果他在 5 秒后未确认,则对话框应自动关闭(因为用户可能不小心打开了它).这类似于您更改屏幕分辨率时在 Windows 上发生的情况(出现警告,如果您不确认,它会恢复到以前的配置).

                  I'm working on an accesibility app. When the user wants to leave the app I show a dialog where he has to confirm he wants to leave, if he doesn't confirm after 5 seconds the dialog should close automatically (since the user probably opened it accidentally). This is similar to what happens on Windows when you change the screen resolution (an alert appears and if you don't confirm it, it reverts to the previous configuration).

                  这就是我显示对话框的方式:

                  This is how I show the dialog:

                  AlertDialog.Builder dialog = new AlertDialog.Builder(this).setTitle("Leaving launcher").setMessage("Are you sure you want to leave the launcher?");
                              dialog.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
                                  @Override
                                  public void onClick(DialogInterface dialog, int whichButton) {
                                      exitLauncher();
                                  }
                              });
                              dialog.create().show();
                  

                  如何在显示 5 秒后关闭对话框?

                  How can I close the dialog 5 seconds after showing it?

                  推荐答案

                  final AlertDialog.Builder dialog = new AlertDialog.Builder(this).setTitle("Leaving launcher").setMessage("Are you sure you want to leave the launcher?");
                  dialog.setPositiveButton("Confirm", new DialogInterface.OnClickListener() {
                      @Override
                      public void onClick(DialogInterface dialog, int whichButton) {
                          exitLauncher();
                      }
                  });     
                  final AlertDialog alert = dialog.create();
                  alert.show();
                  
                  // Hide after some seconds
                  final Handler handler  = new Handler();
                  final Runnable runnable = new Runnable() {
                      @Override
                      public void run() {
                          if (alert.isShowing()) {
                              alert.dismiss();
                          }
                      }
                  };
                  
                  alert.setOnDismissListener(new DialogInterface.OnDismissListener() {
                      @Override
                      public void onDismiss(DialogInterface dialog) {
                          handler.removeCallbacks(runnable);
                      }
                  });
                  
                  handler.postDelayed(runnable, 10000);
                  

                  这篇关于5秒后Android关闭对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Java - 全局的、可重用的加载对话框 下一篇:点击 Android 对话框外部以将其关闭?

                  相关文章

                  最新文章

                  <i id='DU0tt'><tr id='DU0tt'><dt id='DU0tt'><q id='DU0tt'><span id='DU0tt'><b id='DU0tt'><form id='DU0tt'><ins id='DU0tt'></ins><ul id='DU0tt'></ul><sub id='DU0tt'></sub></form><legend id='DU0tt'></legend><bdo id='DU0tt'><pre id='DU0tt'><center id='DU0tt'></center></pre></bdo></b><th id='DU0tt'></th></span></q></dt></tr></i><div id='DU0tt'><tfoot id='DU0tt'></tfoot><dl id='DU0tt'><fieldset id='DU0tt'></fieldset></dl></div>

                      • <bdo id='DU0tt'></bdo><ul id='DU0tt'></ul>
                    1. <tfoot id='DU0tt'></tfoot>

                      <small id='DU0tt'></small><noframes id='DU0tt'>

                      <legend id='DU0tt'><style id='DU0tt'><dir id='DU0tt'><q id='DU0tt'></q></dir></style></legend>