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

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

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

      首次运行时在 ViewPager 中预加载片段视图

      时间:2023-10-04
      • <bdo id='tbssn'></bdo><ul id='tbssn'></ul>

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

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

            <tfoot id='tbssn'></tfoot>

                <tbody id='tbssn'></tbody>

                本文介绍了首次运行时在 ViewPager 中预加载片段视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                我正在使用包含 3 个片段的 ViewPager,每个片段加载一个列表.问题是当应用程序第一次运行并且我滑动到下一个片段时,这个片段需要一些时间来加载(大约 2 秒),然后它的视图才可见.这是一个非常奇怪的行为.我想要的只是一旦应用程序启动,ViewPager 中的所有片段都应该为用户准备好,所以当他们刷过片段时,没有等待时间.我怎样才能做到这一点?

                I'm using ViewPager that holds 3 fragments, each fragment loads a list. The problem is when the application runs for the first time and I swipe to the next fragment, this fragment needs sometime to load (about 2 seconds) before its view is visible. This is a very weird behavior. All I want is once the app has started, all fragments in ViewPager should be ready for user so when they swipe through fragments, there's no wait time. How can I do that?

                推荐答案

                只要调用setOffscreenPageLimit() 在 onCreate() 中(在初始化 ViewPager 之后).OffscreenPageLimit 设置应保留到当前页面任一侧的页面数(在您的情况下为 2).这样,您的所有片段都将被实例化.

                Just call setOffscreenPageLimit() in onCreate() (after initializing ViewPager). The OffscreenPageLimit sets the number of pages that should be retained to either side of the current page (in your case 2). With this all of your fragments will be instantiate.

                (另一种(强烈推荐)可能性是提高列表或列表适配器的性能,因为 2 秒的加载时间听起来不太好)

                (An other (highly recommended) possibility is to increase the performance of your lists or listadapters, because a loading time of 2 seconds doesn't sound good)

                这篇关于首次运行时在 ViewPager 中预加载片段视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                上一篇:如何自定义 CirclePageIndicator? 下一篇:ListView 中的 ViewPager 和 OnItemClickListener

                相关文章

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

                <tfoot id='nrj3E'></tfoot>

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

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