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

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

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

      <tfoot id='tEdiH'></tfoot>

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

        单击中性按钮后是否可以保持对话框打开?

        时间:2023-09-28
          <tbody id='4Trsd'></tbody>
        • <small id='4Trsd'></small><noframes id='4Trsd'>

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

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

                  本文介绍了单击中性按钮后是否可以保持对话框打开?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个包含 3 个 EditText 的对话框,用于获取 ftp 地址、用户名和密码.我使用 .setNeutralButton 创建了一个测试连接"按钮.我让它连接到 ftp 并显示一个带有结果的 Toast,但我不希望测试按钮关闭对话框.如何在连接测试期间保持对话框打开?

                  I have a Dialog with 3 EditTexts that I use to get an ftp address, username, and password. I used .setNeutralButton to create a button to "Test Connection". I got it working to connect to the ftp and show a Toast with the result but I don't want the Test Button to close the Dialog. How can I keep the Dialog open during the connection test?

                  livePreviewChk.setOnClickListener(new OnClickListener() {
                      @Override
                      public void onClick(View v) {
                          LinearLayout lila1 = new LinearLayout(NewSite.this);
                          lila1.setOrientation(1); // 1 is for vertical orientation
                  
                          final EditText serverName = new EditText(NewSite.this);
                          serverName.setHint("Server name");
                  
                          final EditText serverAddress = new EditText(NewSite.this);
                          serverAddress.setHint("Server Address");
                  
                          final EditText username = new EditText(NewSite.this);
                          username.setHint("Username:");
                  
                          final EditText password = new EditText(NewSite.this);
                          password.setHint("Password");
                  
                          AlertDialog.Builder alt_bld = new AlertDialog.Builder(
                                  NewSite.this);
                          alt_bld.setIcon(R.drawable.ftpicon);
                          alt_bld.setTitle("Enter the login details for the host FTP")
                                  .setCancelable(true)
                                  .setPositiveButton("Save",
                                          new DialogInterface.OnClickListener() {
                                              public void onClick(DialogInterface dialog,
                                                      int id) {
                                                  }
                                              }
                                          })
                                  .setNeutralButton("Test Connection",
                                          new DialogInterface.OnClickListener() {
                                              public void onClick(DialogInterface dialog,
                                                      int id) {
                                                  FTPConnector testConnection = new FTPConnector();
                                                  boolean status = testConnection
                                                          .ftpConnect(host, user, pass,
                                                                  port);
                                                  if (status == true) {
                                                      connectionSuccessfull = true;
                                                  } else {
                                                      connectionSuccessfull = false;
                                                  }
                                              }
                                          })
                                  .setNegativeButton("Cancel",
                                          new DialogInterface.OnClickListener() {
                                              public void onClick(DialogInterface dialog,
                                                      int id) {
                                                  // if this button is clicked, just close
                                                  // the dialog box and do nothing
                                                  dialog.cancel();
                                              }
                                          });
                  
                          lila1.addView(serverName);
                          lila1.addView(serverAddress);
                          lila1.addView(username);
                          lila1.addView(password);
                  
                          AlertDialog alert = alt_bld.create();
                          alert.setView(lila1);
                          alert.show();
                      }
                  });
                  

                  推荐答案

                  据我所知,不扩展 Dialog 类是不可能的.但是,使用您拥有的功能,将其放在自己的 Activity 中并使用 Dialog 主题 可能会更容易和更好.您所要做的就是为此将您的代码放入一个新的 Activity 中,并在您的 manifest 中使用 dialog 主题

                  From what I know, it is not possible without extending the Dialog class. However, with the functionality that you have it may be easier and better just to put it in its own Activity and use a Dialog theme. All you have to do is put your code into a new Activity for this and in your manifest use the dialog theme

                  <activity
                          android:name="com.your.package.YourClassName"
                          android:label="YOurLabel"
                          android:theme="@android:style/Theme.Dialog" >
                  </activity>
                  

                  这将提供 Dialog 的外观和感觉,同时包含在它自己的 Activity

                  This will give the look and feel of a Dialog while being contained in its own Activity

                  这是一个 关于扩展对话框的答案.我还没有看透这一切,但看起来如果你选择这个选项,它可能会给你你需要的东西.

                  Here is a SO answer on extending Dialog. I haven't looked through it all but looks like it may give you what you need if you choose this option.

                  这篇关于单击中性按钮后是否可以保持对话框打开?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android-显示自定义对话框 下一篇:如何在 vaadin-flow 中正确指定对话框大小

                  相关文章

                  最新文章

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

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

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

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