• <tfoot id='Xdj3A'></tfoot>
  • <small id='Xdj3A'></small><noframes id='Xdj3A'>

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

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

        点击 Android 对话框外部以将其关闭?

        Tap outside Android dialog to dismiss it?(点击 Android 对话框外部以将其关闭?)
        <legend id='DXnrb'><style id='DXnrb'><dir id='DXnrb'><q id='DXnrb'></q></dir></style></legend>
            <tbody id='DXnrb'></tbody>

                  <bdo id='DXnrb'></bdo><ul id='DXnrb'></ul>
                • <small id='DXnrb'></small><noframes id='DXnrb'>

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

                  <tfoot id='DXnrb'></tfoot>

                  本文介绍了点击 Android 对话框外部以将其关闭?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我想知道是否有可能以某种方式在弹出对话框(或具有对话框主题的 Activity)外部点击,然后通过点击它外部将其关闭?

                  I was wondering if it's possible to somehow tap outside a popup dialog (or an Activity with a dialog theme), and dismiss it by just tapping outside of it?

                  我做了一张快速的图片来说明它:

                  I made a quick picture to illustrate it:

                  通常情况下,您必须按返回键才能关闭对话框,但在 Honeycomb 上,由于所有屏幕空间,选择只在对话框外点击可能会很棒.

                  Normally, you have to press the back key to dismiss the dialogs, but on Honeycomb it could be great to have the option of just tapping outside the dialog, due to all the screen estate.

                  推荐答案

                  我的应用是一个带有 Theme.Holo.Dialog 的单一活动.就我而言,另一个答案不起作用.它只让其他后台应用程序或启动屏幕接收触摸事件.

                  My app is a single activity with Theme.Holo.Dialog. In my case the other answer did not work. It only made the other background apps or the launch screen to receive touch events.

                  我发现使用 dispatchTouchEvent 在我的情况下有效.我认为这也是一个更简单的解决方案.下面是一些示例代码,说明如何使用它来检测带有 Dialog 主题的 Activity 之外的点击:

                  I found that using dispatchTouchEvent works in my case. I think it is also a simpler solution. Here's some sample code on how to use it to detect taps outside the activity with a Dialog theme:

                  @Override
                  public boolean dispatchTouchEvent(MotionEvent ev) {
                      Rect dialogBounds = new Rect();
                      getWindow().getDecorView().getHitRect(dialogBounds);
                  
                      if (!dialogBounds.contains((int) ev.getX(), (int) ev.getY())) {
                          // Tapped outside so we finish the activity
                          this.finish();
                      }
                      return super.dispatchTouchEvent(ev);
                  }
                  

                  这篇关于点击 Android 对话框外部以将其关闭?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                  相关文档推荐

                  Lucene Porter Stemmer not public(Lucene Porter Stemmer 未公开)
                  How to index pdf, ppt, xl files in lucene (java based or python or php any of these is fine)?(如何在 lucene 中索引 pdf、ppt、xl 文件(基于 java 或 python 或 php 中的任何一个都可以)?)
                  KeywordAnalyzer and LowerCaseFilter/LowerCaseTokenizer(KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer)
                  How to search between dates (Hibernate Search)?(如何在日期之间搜索(休眠搜索)?)
                  How to get positions from a document term vector in Lucene?(如何从 Lucene 中的文档术语向量中获取位置?)
                  Java Lucene 4.5 how to search by case insensitive(Java Lucene 4.5如何按不区分大小写进行搜索)
                • <legend id='hgwfH'><style id='hgwfH'><dir id='hgwfH'><q id='hgwfH'></q></dir></style></legend>
                    <tbody id='hgwfH'></tbody>
                  <tfoot id='hgwfH'></tfoot>
                • <i id='hgwfH'><tr id='hgwfH'><dt id='hgwfH'><q id='hgwfH'><span id='hgwfH'><b id='hgwfH'><form id='hgwfH'><ins id='hgwfH'></ins><ul id='hgwfH'></ul><sub id='hgwfH'></sub></form><legend id='hgwfH'></legend><bdo id='hgwfH'><pre id='hgwfH'><center id='hgwfH'></center></pre></bdo></b><th id='hgwfH'></th></span></q></dt></tr></i><div id='hgwfH'><tfoot id='hgwfH'></tfoot><dl id='hgwfH'><fieldset id='hgwfH'></fieldset></dl></div>

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

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