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

        <legend id='au6I1'><style id='au6I1'><dir id='au6I1'><q id='au6I1'></q></dir></style></legend>
      1. <tfoot id='au6I1'></tfoot>

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

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

        定时无模式对话

        时间:2023-08-31
      2. <tfoot id='UNrW1'></tfoot>
        • <i id='UNrW1'><tr id='UNrW1'><dt id='UNrW1'><q id='UNrW1'><span id='UNrW1'><b id='UNrW1'><form id='UNrW1'><ins id='UNrW1'></ins><ul id='UNrW1'></ul><sub id='UNrW1'></sub></form><legend id='UNrW1'></legend><bdo id='UNrW1'><pre id='UNrW1'><center id='UNrW1'></center></pre></bdo></b><th id='UNrW1'></th></span></q></dt></tr></i><div id='UNrW1'><tfoot id='UNrW1'></tfoot><dl id='UNrW1'><fieldset id='UNrW1'></fieldset></dl></div>

              • <bdo id='UNrW1'></bdo><ul id='UNrW1'></ul>
                <legend id='UNrW1'><style id='UNrW1'><dir id='UNrW1'><q id='UNrW1'></q></dir></style></legend>

                  <tbody id='UNrW1'></tbody>

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

                  本文介绍了定时无模式对话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  有什么方法可以显示无模式对话框 - 一个允许用户与对话框之前屏幕上的任何内容进行交互的对话框,但还允许用户在按下时与对话框进行交互?

                  Is there any way to show a modeless dialog--a dialog that allows the user to interact with whatever was on the screen before the dialog but also allows the user to interact with the dialog if pressed?

                  我知道 Toasts,但它们不允许与弹出窗口交互.

                  I know of Toasts, but they don't allow interaction with the popup.

                  我知道对话框,但它们是模态的,不允许与背景交互.

                  I know of Dialogs, but they're modal and don't allow interaction with the background.

                  我知道通知,但我想要在屏幕上可见的东西.

                  I know of Notifications, but I want something that is visibile on screen.

                  我基本上希望能够玩游戏或其他东西,然后出现一个弹出窗口,提示我有一封新电子邮件或其他东西.我可以点击它来查看我的电子邮件,但如果我只想继续玩我的游戏,我可以等待它消失.这在 Android 中可行吗?

                  I basically want to be able to be playing a game or something and a popup appears that I have a new email or something. I can click it to view my email, but I can wait for it to go away if I just want to continue playing my game. Is this possible in Android?

                  推荐答案

                  是的,创建一个样式为 Theme.Dialog 的 Activity.这是一个正常的活动,看起来像一个对话框,同时是无模式的并接受事件.

                  Yes, create an Activity with style Theme.Dialog. This is a normal activity which looks like a dialog, while being modeless and accepting events.

                  一个例子:

                  <activity android:name=".activity.dialog.PhotoDialog"
                            android:label="@string/photo_dialog_title"
                            android:theme="@android:style/Theme.Dialog"/>
                  

                  已编辑:

                  确实 Theme.Dialog 模糊了底层活动并使其无法访问.我在这里有类似的要求,我必须显示带有文本和取消按钮的上传进度对话框.主要问题在于设置 WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL 和重置 WindowManager.LayoutParams.FLAG_DIM_BEHIND.

                  Indeed Theme.Dialog blurs the underlying activity and makes it unaccessible. I had a similar requirement here I had to show upload progress dialog with text and cancel button. The main catch is in setting WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL and resetting WindowManager.LayoutParams.FLAG_DIM_BEHIND.

                  创建了一个包含自定义内容的对话框:

                  Created a Dialog with custom content:

                      if (progressDialog == null) {
                              progressDialog = new Dialog(activityRequestingProgressDialog);
                              progressDialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
                              progressDialog.setContentView(R.layout.progress_upload);
                              progressBar = (ProgressBar) progressDialog.findViewById(R.id.progressBar);
                              progressText = (TextView) progressDialog.findViewById(R.id.progressText);
                              progressText.setText("0 %");
                              progressText.setTextSize(18);
                              Button buttonCancel = (Button) progressDialog.findViewById(R.id.btnCancel);
                              buttonCancel.setOnClickListener(new View.OnClickListener() {
                                  public void onClick(View view) {
                                      cancelProgressDialog();
                                      stopUpload("Upload cancelled.");
                                  }
                              });
                              Window window = progressDialog.getWindow();
                              window.setFlags(WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL,
                                      WindowManager.LayoutParams.FLAG_NOT_TOUCH_MODAL);
                              window.clearFlags(WindowManager.LayoutParams.FLAG_DIM_BEHIND);
                              window.setGravity(Gravity.BOTTOM);
                              progressDialog.show();
                          }
                  
                          progressText.setText(text);
                          progressBar.setProgress(percent);
                  

                  这是这个对话框的布局:

                  And this is the layout for this Dialog:

                  <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
                            android:id="@+id/progressDialog"
                            android:orientation="vertical"
                            android:layout_height="wrap_content"
                            android:layout_width="wrap_content"
                            android:layout_centerVertical="true">
                  
                  <TextView android:layout_width="wrap_content"
                            android:layout_height="wrap_content"
                            android:layout_gravity="center"
                            android:textSize="18sp"
                            android:padding="10dp"
                            android:text="@string/progress_title"/>
                  
                  <LinearLayout android:id="@+id/progressDialog"
                                android:orientation="horizontal"
                                android:layout_height="wrap_content"
                                android:layout_width="wrap_content"
                                android:padding="10dp"
                                android:layout_centerVertical="true">
                  
                      <ProgressBar android:id="@+id/progressBar"
                                   android:layout_width="150dp"
                                   android:layout_height="34dp"
                                   android:paddingRight="10dp"
                                   android:max="100"
                                   android:progress="0"
                                   android:fadingEdge="vertical"
                                   style="?android:attr/progressBarStyleHorizontal"/>
                  
                      <TextView android:layout_width="wrap_content"
                                android:layout_height="wrap_content"
                                android:layout_gravity="center"
                                android:id="@+id/progressText"
                                android:paddingRight="10dp"/>
                  
                      <Button android:layout_height="40dp"
                              android:layout_width="80dp"
                              android:id="@+id/btnCancel"
                              android:text="@string/dialog_cancel"/>
                  
                  </LinearLayout>
                  </LinearLayout>
                  

                  这篇关于定时无模式对话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android:首次运行弹出对话框 下一篇:如何更改默认的黑色暗淡背景“颜色"?(不是

                  相关文章

                  最新文章

                1. <tfoot id='bWndG'></tfoot>

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

                  • <bdo id='bWndG'></bdo><ul id='bWndG'></ul>

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

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