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

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

      • <bdo id='YGJh3'></bdo><ul id='YGJh3'></ul>
    1. <tfoot id='YGJh3'></tfoot>
        <legend id='YGJh3'><style id='YGJh3'><dir id='YGJh3'><q id='YGJh3'></q></dir></style></legend>

        关闭自定义对话框?

        时间:2023-09-01

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

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

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

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

                  问题描述

                  我正在尝试制作一个自定义对话框以在此对话框中显示一个视图.这是生成器代码:

                  I'm trying to make a custom dialog to show a view in this dialog. This is the Builder code:

                  //Getting the layout
                  LayoutInflater inflater = (LayoutInflater) getSystemService(LAYOUT_INFLATER_SERVICE);
                  View layout = inflater.inflate(R.layout.custom_dialog_simple,
                                                 (ViewGroup) findViewById(R.id.rlDialogSimple));
                  
                  //Change Text and on click
                  TextView tvDialogSimple = (TextView) layout.findViewById(R.id.tvDialogSimple);
                  tvDialogSimple.setText(R.string.avisoComprobar);
                  Button btDialogSimple = (Button) layout.findViewById(R.id.btDialogSimple);
                  btDialogSimple.setOnClickListener(new OnClickListener() {
                  
                      public void onClick(View v) {
                          //Do some stuff
                  
                          //Here i want to close the dialog
                      }
                  });
                  
                  AlertDialog.Builder builder = new AlertDialog.Builder(AcPanelEditor.this);
                  builder.setView(layout);
                  AlertDialog alert = builder.create();
                  alert.show();
                  

                  所以,我想关闭 btDialogSimple 的 onClick 中的对话框.我该怎么做?我不知道如何从 onclicklistener 中调用dismiss方法.

                  So, i want to dismiss the dialog in the onClick of btDialogSimple. How i can do it? I don't know how to call the dismiss method from inside a onclicklistener.

                  我的按钮有自定义布局,所以我不想制作 builder.setPositiveButton.

                  My buttons have a custom layout, so i don't want to make a builder.setPositiveButton.

                  有什么想法吗?

                  推荐答案

                  您必须将 AlertDialog 保存到您的父类属性中,然后使用如下内容:

                  You have to save the AlertDialog to your parent class property, then use something like this:

                  class parentClass ........ {
                  private AlertDialog alert=null;
                  ........
                  public void onClick(View v) {
                          //Do some stuff
                  
                          //Here i want to close the dialog
                          if (parentClass.this.alert!=null)            
                          parentClass.this.alert.dismiss();
                      }
                  ........
                  this.alert = builder.create();
                  this.alert.show();
                  

                  }

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

                  上一篇:当 Android Dialog 被解除时,你能触发一个事件吗 下一篇:获取位置 Android 时出错(GPS 和网络)

                  相关文章

                  最新文章

                  1. <legend id='67yBd'><style id='67yBd'><dir id='67yBd'><q id='67yBd'></q></dir></style></legend>
                      <bdo id='67yBd'></bdo><ul id='67yBd'></ul>

                    <small id='67yBd'></small><noframes id='67yBd'>

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