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

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

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

          <bdo id='kyWZN'></bdo><ul id='kyWZN'></ul>

        5秒后Android关闭对话框?

        时间:2023-06-28

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

              <legend id='9xGl7'><style id='9xGl7'><dir id='9xGl7'><q id='9xGl7'></q></dir></style></legend>

              <small id='9xGl7'></small><noframes id='9xGl7'>

              <tfoot id='9xGl7'></tfoot>
                <tbody id='9xGl7'></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关闭对话框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

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

                  相关文章

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

                    <tfoot id='88rDG'></tfoot>

                    <small id='88rDG'></small><noframes id='88rDG'>