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

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

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

        <bdo id='V4xfq'></bdo><ul id='V4xfq'></ul>
    1. Android ViewPager 方向改变

      时间:2023-10-03
      <legend id='LRqVJ'><style id='LRqVJ'><dir id='LRqVJ'><q id='LRqVJ'></q></dir></style></legend>
      <tfoot id='LRqVJ'></tfoot>
    2. <i id='LRqVJ'><tr id='LRqVJ'><dt id='LRqVJ'><q id='LRqVJ'><span id='LRqVJ'><b id='LRqVJ'><form id='LRqVJ'><ins id='LRqVJ'></ins><ul id='LRqVJ'></ul><sub id='LRqVJ'></sub></form><legend id='LRqVJ'></legend><bdo id='LRqVJ'><pre id='LRqVJ'><center id='LRqVJ'></center></pre></bdo></b><th id='LRqVJ'></th></span></q></dt></tr></i><div id='LRqVJ'><tfoot id='LRqVJ'></tfoot><dl id='LRqVJ'><fieldset id='LRqVJ'></fieldset></dl></div>
        • <bdo id='LRqVJ'></bdo><ul id='LRqVJ'></ul>

              <tbody id='LRqVJ'></tbody>

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

                本文介绍了Android ViewPager 方向改变的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我已阅读 @antonyt 的 对此 StackOverflow 问题,FragmentPagerAdapter 将在方向更改时尝试重用 FragmentManager.findFragmentByTag() 找到的现有片段.

                I have read from @antonyt's answer to this StackOverflow question that FragmentPagerAdapter will try to reuse an existing fragment found by FragmentManager.findFragmentByTag() upon orientation change.

                我已经试过了.FragmentPagerAdaptergetItem(int) 在第一次需要 Fragment 时被调用.在方向改变时,getItem 不会被调用,这与 @antonyt's 的回答一致.但是为什么又调用了FragmentonCreate()呢?我以为它没有被破坏?

                I have tried this. getItem(int) of the FragmentPagerAdapter is called when the Fragment is first needed. Upon orientation change, getItem is not called, which is in accordance with @antonyt's answer. But why is it that onCreate() of the Fragment is called again? I thought it was not destroyed?

                推荐答案

                所有没有设置setRetainInstance(true)的片段在方向改变时被销毁.方向改变后,所有片段都由片段管理器重新创建和重新附加(因此片段贯穿整个生命周期).

                All fragments which not set setRetainInstance(true) are destroyed on orientation change. After orientation changed all fragments are recreated and reattach by fragment manager (so fragment goes throught entire lifecycle).

                ViewPager 附加的所有片段都被添加到带有特殊标签的片段管理器中.ViewPager 尝试重用在方向改变后重新创建的片段(通过在片段管理器中搜索标签).如果这样的片段不存在,则调用 FragmentPagerAdapter.getItem(int) 来创建新片段.

                All fragment attached by ViewPager are added to fragment manager with special tag. ViewPager try to reuse fragment recreated after orientation changed (by searching for tag in fragment manager). If such fragment don't exist then FragmentPagerAdapter.getItem(int) is called to create new fragment.

                这篇关于Android ViewPager 方向改变的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:在适配器的构造函数中传递片段 下一篇:片段内的Android setShareIntent

                相关文章

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

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

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