<legend id='6ILol'><style id='6ILol'><dir id='6ILol'><q id='6ILol'></q></dir></style></legend>

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

        <small id='6ILol'></small><noframes id='6ILol'>

      1. <tfoot id='6ILol'></tfoot>
        • <bdo id='6ILol'></bdo><ul id='6ILol'></ul>
      2. Android:旋转更改后对话框等恢复

        时间:2023-08-30

              <legend id='8EYBO'><style id='8EYBO'><dir id='8EYBO'><q id='8EYBO'></q></dir></style></legend>
            • <small id='8EYBO'></small><noframes id='8EYBO'>

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

                  本文介绍了Android:旋转更改后对话框等恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  旋转屏幕后如何恢复对话框等?例如,弹出一个 alertDialog 告诉用户一些信息.然后用户将屏幕旋转到另一个方向.如何恢复alertDialog?任何人都可以指导我这样做吗?谢谢!

                  How to restore the dialog etc after rotating the screen? For example, pop up an alertDialog to tell user some information. then the user rotate the screen to another orientation. How to restore the alertDialog? Can any one guide me to do it? Thanks!

                  稍后添加:

                  我查看了android源代码并找到了这些东西:

                  I looked into the android source code and find these things:

                  对话框存储在mManagedDialogs中,相关信息为:

                  Dialogs are stored in mManagedDialogs, and the related information is:

                  mManagedDialogs = new SparseArray<ManagedDialog>();
                  

                  onSaveInstanceState相关:

                  final void performSaveInstanceState(Bundle outState) {
                      onSaveInstanceState(outState);
                      saveManagedDialogs(outState);
                  }
                  

                  saveManagedDialogs中,与mManagedDialogs有关.

                  onRestoreInstanceState相关:

                  final void performRestoreInstanceState(Bundle savedInstanceState) {
                      onRestoreInstanceState(savedInstanceState);
                      restoreManagedDialogs(savedInstanceState);
                  }
                  

                  restoreManagedDialogs中,与mManagedDialogs有关.

                  如您所见,对于高级功能,您必须自己完成保存和恢复工作.当您拥有大量自定义对话框时,这可能是一场噩梦.我没有尝试过复杂的对话框(例如输入了 EdiText、listView).通过这种方式,我想警告用户:在对话框中输入信息时切勿旋转屏幕......或者,在显示对话框时动态锁定旋转.

                  As you can see, for advanced feature, you must do the saving and restoring job by yourself. It may be a night mare when you have tons customized dialogs. I have not tried the complex dialog (has input EdiText, listView, say). In this way, I'd like to warn users: Never rotate the screen when inputing your info in the dialog... OR, lock the rotation dynamically when showing the dialog.

                  感谢所有回答我的人.希望我的信息也能帮到你.

                  Thanks for all the people who answered me. Hope my information help you too.

                  推荐答案

                  我采取的方法是不允许操作系统在布局配置更改后重新启动您的活动.为此,请在清单文件中要阻止重新启动的活动中添加此行:

                  The approach I took was to not allow the OS to restart your activity after the layout configuration change. To accomplish this, add this line within activities that you want to prevent from restarting in your manifest file:

                   <activity
                   android:configChanges="orientation|keyboard"
                   ...
                   >
                  

                  您可以选择在代码中处理配置更改,以防您想要手动进行一些布局更改,例如从 XML 重新加载新视图.这是通过覆盖 Activity 类中的 onConfigurationChanged() 方法来完成的:

                  Optionally, you can handle the configuration change in code in case there are some layout changes you want to make manually, such as reloading a new view from XML. This is done by overwriting the onConfigurationChanged() method in your Activity class:

                  @Override
                  public void onConfigurationChanged(Configuration newConfig)
                  {
                      //Handle config changes here, paying attention to
                      //the newConfig.orientation value
                      super.onConfigurationChanged(newConfig);
                  }
                  

                  在配置更改列表中添加了|keyboard"

                  Added "|keyboard" to the list of config changes

                  这篇关于Android:旋转更改后对话框等恢复的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:在 5.0+ 上更改对话框文本颜色 下一篇:onOptionsItemSelected android中的警报对话框

                  相关文章

                  最新文章

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

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