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

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

        <tfoot id='Ox5zt'></tfoot>
        <i id='Ox5zt'><tr id='Ox5zt'><dt id='Ox5zt'><q id='Ox5zt'><span id='Ox5zt'><b id='Ox5zt'><form id='Ox5zt'><ins id='Ox5zt'></ins><ul id='Ox5zt'></ul><sub id='Ox5zt'></sub></form><legend id='Ox5zt'></legend><bdo id='Ox5zt'><pre id='Ox5zt'><center id='Ox5zt'></center></pre></bdo></b><th id='Ox5zt'></th></span></q></dt></tr></i><div id='Ox5zt'><tfoot id='Ox5zt'></tfoot><dl id='Ox5zt'><fieldset id='Ox5zt'></fieldset></dl></div>
      1. 如何知道片段何时在 viewpager 中实际可见

        时间:2023-10-04

        <tfoot id='3fdd9'></tfoot>
          <bdo id='3fdd9'></bdo><ul id='3fdd9'></ul>
          1. <small id='3fdd9'></small><noframes id='3fdd9'>

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

                1. 本文介绍了如何知道片段何时在 viewpager 中实际可见的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我在 ViewPager 中使用了 4 个片段,因为 ViewPager 会提前加载上一个和下一个片段,并且在片段之间导航时不会调用生命周期方法.那么有什么方法可以检测 Fragment 何时真正可见.提前致谢.

                  I am using 4 fragments inside a ViewPager ,as ViewPager load the previous and next fragment in advance ,and no lifecycle method is called when navigating between fragments. So is there any way to detect when Fragment is actually visible. Thanks in Advance.

                  推荐答案

                  当然.假设 viewPager 是您的 ViewPager 实例,请使用:viewPager.getCurrentItem().

                  Of course. Assuming that viewPager is your instance of the ViewPager, use: viewPager.getCurrentItem().

                  在您的 Fragment 中,您可以检查其实例是否对用户可见,如下所示:

                  Within your Fragment you can check if its instance is visible to the user like so:

                  @Override
                  public void setUserVisibleHint(boolean visible) {
                      super.setUserVisibleHint(visible);
                      if (visible) {
                          Log.i("Tag", "Reload fragment");
                      }
                  }
                  

                  在提出问题之前,请务必彻底搜索答案.例如,您应该首先检查的地方是:https:///developer.android.com/reference/android/support/v4/view/ViewPager.html

                  Always make sure that you search for answers throughly before asking your question. For instance, the first place you should check would be: https://developer.android.com/reference/android/support/v4/view/ViewPager.html

                  这篇关于如何知道片段何时在 viewpager 中实际可见的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:如何在 2 个 ViewPager 之间产生视差效果? 下一篇:圆形 ViewPager.片段在第一轮后无法正常工作

                  相关文章

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

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

                    • <bdo id='j58wq'></bdo><ul id='j58wq'></ul>
                  1. <tfoot id='j58wq'></tfoot>

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