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

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

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

      1. 如何在自定义对话框中创建正面和负面按钮

        时间:2023-08-30

            • <tfoot id='Eanse'></tfoot>

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

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

                  <tbody id='Eanse'></tbody>
                  <bdo id='Eanse'></bdo><ul id='Eanse'></ul>
                  <i id='Eanse'><tr id='Eanse'><dt id='Eanse'><q id='Eanse'><span id='Eanse'><b id='Eanse'><form id='Eanse'><ins id='Eanse'></ins><ul id='Eanse'></ul><sub id='Eanse'></sub></form><legend id='Eanse'></legend><bdo id='Eanse'><pre id='Eanse'><center id='Eanse'></center></pre></bdo></b><th id='Eanse'></th></span></q></dt></tr></i><div id='Eanse'><tfoot id='Eanse'></tfoot><dl id='Eanse'><fieldset id='Eanse'></fieldset></dl></div>
                • 本文介绍了如何在自定义对话框中创建正面和负面按钮的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想创建一个自定义对话框.所以我创建了一个模板dialog_change"并打开了对话框.

                  I want to create a custom dialog. So i create a template 'dialog_change' and I open the dialog.

                  Dialog myDialog = new Dialog(Overview.this);
                  myDialog.setContentView(R.layout.dialog_change);
                  myDialog.setTitle("My Custom Dialog Title");
                  myDialog.show();
                  

                  现在我想在底部添加两个按钮(一个正按钮和一个负按钮).我该怎么做?

                  Now i want to add two button (one positive and one negative button), at the bottom. How can i do that?

                  推荐答案

                  我只是制作你自己的自定义类来模拟一个 AlertDialog,这样你就可以使用你自己的布局而不附加任何字符串.(如果您想要一个完全样式化的 AlertDialog,则存在一些无法完全摆脱框架的奇怪问题).类似这样的东西,但您可以随意扩展它:

                  I'd just make your own custom class to simulate an AlertDialog, this way you can use your own layout with no strings attached. (There are some weird issues where you can't fully get rid of the frame if you want a fully styled AlertDialog). Something like this, but you can expand this as fully as you want:

                  public class CustomDialog extends Dialog {
                      private Button positive, negative;
                  
                      public CustomDialog(Context context) {
                          super(context);
                          initialize(context);
                      }
                  
                      protected CustomDialog(Context context, boolean cancelable, OnCancelListener cancelListener) {
                          super(context, cancelable, cancelListener);
                          initialize(context);
                      }
                  
                      public CustomDialog(Context context, int theme) {
                          super(context, theme);
                          initialize(context);
                      }
                  
                      private void initialize(Context c) {
                          //Inflate your layout, get a handle for the buttons
                  
                          positive = (Button)layout.findViewById(R.id.positive):
                          negative = (Button)layout.findViewById(R.id.negative):
                  
                          positive.setVisibility(View.GONE);
                          negative.setVisibility(View.GONE);
                      }
                  
                      public void setPositiveButton(String buttonText, View.OnClickListener listener) {
                          positive.setText(buttonText);
                          positive.setOnClickListener(listener);
                          positive.setVisibility(View.VISIBLE);
                      }
                  
                      public void setNegativeButton(String buttonText, View.OnClickListener listener) {
                          negative.setText(buttonText);
                          negative.setOnClickListener(listener);
                          negative.setVisibility(View.VISIBLE);
                      }
                  }
                  

                  这篇关于如何在自定义对话框中创建正面和负面按钮的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:无论设备如何,Android 中的完全自定义对话框都具 下一篇:整个对话框的Android onTouchListener

                  相关文章

                  最新文章

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

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

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

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

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