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

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

  • <small id='AR83G'></small><noframes id='AR83G'>

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

      1. 对话框问题:添加内容前必须调用requestFeature()

        时间:2023-08-30

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

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

          1. <legend id='VgLTc'><style id='VgLTc'><dir id='VgLTc'><q id='VgLTc'></q></dir></style></legend>

                  <bdo id='VgLTc'></bdo><ul id='VgLTc'></ul>
                • 本文介绍了对话框问题:添加内容前必须调用requestFeature()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我正在创建一个包含 EditText 的自定义对话框,以便我可以从用户那里获取文本数据:

                  I'm creating a custom dialog containing an EditText so that I can get text data from the user:

                  final EditText newKey = (EditText) findViewById(R.id.dialog_result);
                  AlertDialog.Builder keyBuilder = new AlertDialog.Builder(StegDroid.this);
                  keyBuilder
                  .setCancelable(false)
                  .setPositiveButton("Try Again", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                          Log.v("Dialog","New Key: "+newKey.getText().toString());
                      }
                  })
                  .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int id) {
                              dialog.cancel();
                         }
                     });
                  AlertDialog dialog = keyBuilder.create();
                  dialog.setTitle("Decryption Failed");
                  dialog.setContentView(R.layout.decrypt_failed_dialog);
                  dialog.show();
                  

                  但是我总是遇到这个异常:

                  However I always get this exception:

                  01-11 18:49:00.507: ERROR/AndroidRuntime(3461): android.util.AndroidRuntimeException: requestFeature() must be called before adding content
                  01-11 18:49:00.507: ERROR/AndroidRuntime(3461):     at com.android.internal.policy.impl.PhoneWindow.requestFeature(PhoneWindow.java:181)
                  01-11 18:49:00.507: ERROR/AndroidRuntime(3461):     at com.android.internal.app.AlertController.installContent(AlertController.java:199)
                  01-11 18:49:00.507: ERROR/AndroidRuntime(3461):     at android.app.AlertDialog.onCreate(AlertDialog.java:251)
                  
                  ...
                  

                  dialog.show() 行.我应该怎么做才能摆脱这种情况?

                  at the line of dialog.show(). What should I be doing to get rid of this?

                  推荐答案

                  你需要在创建对话框之前设置自定义视图.如果您使用 AlertDialogsetView(View) 而不是 setContentView()>.

                  You need to set the custom view before creating the dialog. Also you need to use setView(View) instead of setContentView() if you are using the default positive and negative buttons provided for you by the AlertDialog.

                  final EditText newKey = (EditText) findViewById(R.id.dialog_result);
                  AlertDialog.Builder keyBuilder = new AlertDialog.Builder(StegDroid.this);
                  keyBuilder
                  .setCancelable(false)
                  .setPositiveButton("Try Again", new DialogInterface.OnClickListener() {
                      public void onClick(DialogInterface dialog, int id) {
                          Log.v("Dialog","New Key: "+newKey.getText().toString());
                      }
                  })
                  .setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
                         public void onClick(DialogInterface dialog, int id) {
                              dialog.cancel();
                         }
                     });
                  keyBuilder.setTitle("Decryption Failed");
                  keyBuilder.setView(getLayoutInflater().inflate(R.layout.decrypt_failed_dialog, null));
                  AlertDialog dialog = keyBuilder.create();
                  dialog.show();
                  

                  这篇关于对话框问题:添加内容前必须调用requestFeature()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Kotlin - Android 中的自定义对话框 下一篇:Android - 对话框中的共享元素转换

                  相关文章

                  最新文章

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

                    <tfoot id='WBcoC'></tfoot>

                    1. <legend id='WBcoC'><style id='WBcoC'><dir id='WBcoC'><q id='WBcoC'></q></dir></style></legend>