• <legend id='bS5Jx'><style id='bS5Jx'><dir id='bS5Jx'><q id='bS5Jx'></q></dir></style></legend>

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

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

        <i id='bS5Jx'><tr id='bS5Jx'><dt id='bS5Jx'><q id='bS5Jx'><span id='bS5Jx'><b id='bS5Jx'><form id='bS5Jx'><ins id='bS5Jx'></ins><ul id='bS5Jx'></ul><sub id='bS5Jx'></sub></form><legend id='bS5Jx'></legend><bdo id='bS5Jx'><pre id='bS5Jx'><center id='bS5Jx'></center></pre></bdo></b><th id='bS5Jx'></th></span></q></dt></tr></i><div id='bS5Jx'><tfoot id='bS5Jx'></tfoot><dl id='bS5Jx'><fieldset id='bS5Jx'></fieldset></dl></div>
      1. <tfoot id='bS5Jx'></tfoot>
      2. Android - java.lang.IllegalArgumentException 在 2.1 和低 a

        时间:2023-08-30
          • <bdo id='TRbPl'></bdo><ul id='TRbPl'></ul>

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

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

                    <tbody id='TRbPl'></tbody>
                • <legend id='TRbPl'><style id='TRbPl'><dir id='TRbPl'><q id='TRbPl'></q></dir></style></legend>
                  本文介绍了Android - java.lang.IllegalArgumentException 在 2.1 和低 android 上创建对话框时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我从 SDK 版本的手机收到以下错误消息 <8. 我刚刚在安卓市场上发布了这个应用程序,在发布之前我的测试手机是 HTC Thunderbolt 和 Droid X.根本没有这个问题.

                  I'm getting the below error message from phones that are SDK version < 8. I just released this app on the android market and prior to release my test phones were a HTC Thunderbolt and the Droid X. Neither had this problem at all.

                  我通过 Flurry 收到此错误报告.我无法直接对此进行测试,因为我没有带有 SDK < 的手机8 并且由于某种原因,我无法让我的模拟器启动低于为应用程序设置的默认 SDK 的版本.

                  I'm getting this error report through Flurry. I'm not able to test this directly because I don't have a phone with SDK < 8 and for some reason I can't get my emulator to start a lower version than the default SDK set for an app.

                  java.lang.IllegalArgumentException, android.app.Activity.createDialog:880 -(Activity#onCreateDialog 没有为 id 1 创建对话框)

                  java.lang.IllegalArgumentException, android.app.Activity.createDialog:880 - (Activity#onCreateDialog did not create a dialog for id 1)

                  下面是我实现的 onCreateDialog(int id).

                  Below is the onCreateDialog(int id) that i've implemented.

                  @Override
                  protected Dialog onCreateDialog(int id) {
                      super.onCreateDialog(id);
                      Dialog dialog = null;
                  
                      switch(id){
                      case 1:
                          dialog = new CustomCalcDialog(this);
                          dialog.setTitle("Enter Shipping %");
                          activeTextView = shippingPercent;
                          dialog.show();
                          dialog = null;
                          break;
                      case 2:
                          dialog = new CustomCalcDialog(this);
                          dialog.setTitle("Enter Tax Rate");
                          activeTextView = taxPercent;
                          dialog.show();
                          dialog = null;
                          break;
                      case 3:
                          dialog = new CustomCalcDialog(this);
                          dialog.setTitle("Enter Commission %");
                          activeTextView = commissionPercent;
                          dialog.show();
                          dialog = null;
                          break;
                      case 4:
                          dialog = new CustomCalcDialog(this);
                          dialog.setTitle("Calculate Subtotal");
                          activeTextView = productSubtotal;
                          dialog.show();
                          dialog = null;
                          break;
                      case 5:
                          dialog = new CustomCalcDialog(this);
                          dialog.setTitle("Additional Shipping");
                          activeTextView = addShipping;
                          dialog.show();
                          dialog = null;
                          break;
                      case 6:
                          dialog = new BackgroundOptionsDialog(this);
                          dialog.setTitle("Choose Background:");
                          dialog.show();
                          dialog = null;
                          break;
                      default:
                          dialog = null;
                      }
                      return dialog;
                  }
                  

                  下面是关闭对话框的方式.

                  And below is how the Dialog is being dismissed.

                  private void registerListeners () {
                  
                          enterTotal.setOnClickListener(new View.OnClickListener() {
                  
                              @Override
                              public void onClick(View v) {
                                  try {
                                      calcLogic(EQUALS);
                                  }catch(Exception ex){}
                                  operatorChange = DONT_CHANGE;
                  
                                  activeTextView.setText(calcDialogDisplay.getText().toString());
                  
                                  try {
                                      if ((Float.parseFloat(calcDialogDisplay.getText().toString())) < 0) {}
                                  }catch(Exception ex) {
                                      activeTextView.setText("0");
                                  }
                                  mathCalculations();
                                  CustomCalcDialog.this.dismiss();
                              }
                          });
                  

                  推荐答案

                  也遇到了这个问题,用下面的方法解决了:

                  Had the problem also and solved it with the following:

                  -不要在方法中返回空对话框:protected Dialog onCreateDialog(int id)

                  -Don't return a null Dialog in method: protected Dialog onCreateDialog(int id)

                  在 Android 2.1 中的 Activity.java 中,第 871 行引发了错误.

                  In Android 2.1 in Activity.java the error was raised on line 871.

                  private Dialog createDialog(Integer dialogId, Bundle state) {
                  869         final Dialog dialog = onCreateDialog(dialogId);
                  870         if (dialog == null) {
                  871             throw new IllegalArgumentException("Activity#onCreateDialog did "
                  872                     + "not create a dialog for id " + dialogId);
                  873         }
                  874         dialog.dispatchOnCreate(state);
                  875         return dialog;
                  876     }
                  

                  如果您在以后的 Android 中查看,则会检查空 Dialog,并且它会返回并处理.所以在这里它起作用了.

                  If you look in later Android there is a check for a null Dialog and it's handeld with a return. So here it works.

                  -不要使用 Bundle(在 API8 中更改):

                  -Don't use Bundle (changed in API8):

                  受保护的对话框 onCreateDialog(int id, Bundle bundle);

                  protected Dialog onCreateDialog(int id, Bundle bundle);

                  使用:

                  受保护的对话框 onCreateDialog(int id);

                  protected Dialog onCreateDialog(int id);

                  -我还使用了以下检查(有一个带有自定义对话框的特殊情况):

                  -I also used the following check (had a special case with a custom dialog):

                      if(Build.VERSION.SDK_INT <= Build.VERSION_CODES.ECLAIR_MR1) {
                          return dialog;
                      } else {
                          return null;
                      }
                  

                  也许它可以帮助某人......

                  Maybe it helps someone...

                  这篇关于Android - java.lang.IllegalArgumentException 在 2.1 和低 android 上创建对话框时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Android - FEATURE_NO_TITLE 不起作用 下一篇:Android:对话框在 droid 3 上有额外的、丑陋的空间

                  相关文章

                  最新文章

                • <small id='5PBlf'></small><noframes id='5PBlf'>

                    <legend id='5PBlf'><style id='5PBlf'><dir id='5PBlf'><q id='5PBlf'></q></dir></style></legend>

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

                      • <bdo id='5PBlf'></bdo><ul id='5PBlf'></ul>