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

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

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

      1. Android:对话框关闭而不调用关闭

        时间:2023-08-30
      2. <small id='LMNIy'></small><noframes id='LMNIy'>

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

                1. <i id='LMNIy'><tr id='LMNIy'><dt id='LMNIy'><q id='LMNIy'><span id='LMNIy'><b id='LMNIy'><form id='LMNIy'><ins id='LMNIy'></ins><ul id='LMNIy'></ul><sub id='LMNIy'></sub></form><legend id='LMNIy'></legend><bdo id='LMNIy'><pre id='LMNIy'><center id='LMNIy'></center></pre></bdo></b><th id='LMNIy'></th></span></q></dt></tr></i><div id='LMNIy'><tfoot id='LMNIy'></tfoot><dl id='LMNIy'><fieldset id='LMNIy'></fieldset></dl></div>
                2. <tfoot id='LMNIy'></tfoot>
                    <tbody id='LMNIy'></tbody>
                  本文介绍了Android:对话框关闭而不调用关闭的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我有一个执行一些验证的对话框(如下).你的问题是,显示 Toast 后对话框被关闭,而我没有调用关闭.我需要展示 toast 并保持对话框打开以更正错误.

                  I have a dialog which performs some validation (below). Thee problem is, the dialog is dismissed after the Toast is displayed, without me calling dismiss. I need to show the toast and keep the dialog open to correct the error.

                  final EditText txtName = new EditText(this);
                  AlertDialog.Builder dlgAdd = new AlertDialog.Builder(this)
                      .setTitle(R.string.create_category)
                      .setMessage(R.string.name)
                      .setView(txtName)
                      .setPositiveButton(R.string.ok, new OnClickListener() {
                          @Override
                          public void onClick(DialogInterface dialog, int which) {
                              String newCatName = txtName.getText().toString().trim(); // Converts the value of getText to a string.
                              if (newCatName != null && newCatName .length() ==0)
                              {  
                                  Toast.makeText(ManageCategories.this, R.string.err_name_required, 3500).show();
                  
                              } else {
                                  try {
                                      boolean alreadyExists = mDatabaseAdapter.getCategoryIDs(newCatName).length > 0;// ids of cats with this name
                                      if(alreadyExists) {
                                          Toast.makeText(ManageCategories.this, R.string.categoryAlreadyExists, 3500).show();
                                      } else {
                                          mDatabaseAdapter.addCategory(newCatName);
                                      }
                                  }catch(Exception ex){
                                      Toast.makeText(ManageCategories.this, R.string.error+':'+ ex.getLocalizedMessage(), 3500).show();
                              }
                              }
                          }
                      }).setNegativeButton(R.string.cancel, new DialogInterface.OnClickListener() {
                             public void onClick(DialogInterface dialog, int id) {
                                  dialog.cancel();
                             }
                  });
                  dlgAdd.show();
                  

                  推荐答案

                  我猜你并没有像这里的 Android 文档中提到的那样创建和显示对话框 http://developer.android.com/guide/topics/ui/dialogs.html 使用 OnCreateDialog 函数

                  My guess is that you are not creating and showing dialog as mentioned in the Android docs here http://developer.android.com/guide/topics/ui/dialogs.html using OnCreateDialog functions

                  请按照文档中的说明进行操作,如果仍然无法正常工作,请告知我们.

                  Please do as mentioned in the docs and let us know if it still does not work.

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

                  上一篇:如何更改对话框的颜色 下一篇:Android 在警报对话框中设置文本

                  相关文章

                  最新文章

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

                      <bdo id='Lj5Sb'></bdo><ul id='Lj5Sb'></ul>
                  1. <tfoot id='Lj5Sb'></tfoot>

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