• <small id='4Hpu9'></small><noframes id='4Hpu9'>

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

      <tfoot id='4Hpu9'></tfoot>
      • <bdo id='4Hpu9'></bdo><ul id='4Hpu9'></ul>
      1. 如何让我的 ViewPager 一次只加载一个页面,即 setOffscreenPageLimit(0);

        时间:2023-10-04

        <tfoot id='jT4mP'></tfoot>
            • <bdo id='jT4mP'></bdo><ul id='jT4mP'></ul>
                  <tbody id='jT4mP'></tbody>

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

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

                  <legend id='jT4mP'><style id='jT4mP'><dir id='jT4mP'><q id='jT4mP'></q></dir></style></legend>
                  本文介绍了如何让我的 ViewPager 一次只加载一个页面,即 setOffscreenPageLimit(0);的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  我知道我可以给 setOffscreenPageLimit(int) 的最小数字是 1.但由于内存问题,我需要一次加载一页.

                  I understand the lowest number I can give setOffscreenPageLimit(int) is 1. but I need to load one page at a time because memory problems.

                  我将不得不使用旧样式的 tabhost 等吗?或者有没有办法/hack我可以让我的viewPager一次加载一个页面?

                  Am i going to have to use the old style tabhost etc? or is there a way/hack I can make my viewPager load one page at a time?

                  我的适配器使用 ViewHolder 模式扩展 BaseAdapter.

                  My Adapter extends BaseAdapter with the ViewHolder patern.

                  推荐答案

                  我遇到了同样的问题,我找到了解决方案:

                  步骤:

                  1) 首先从 CustomViewPager 类shared&resourcekey=0-tKADcOLf61mco5p5C-Ca5w" rel="nofollow noreferrer">这个链接.

                  1) First Download the CustomViewPager Class from this link.

                  2) 如下所述使用该类:

                  在 Java 中:

                  CustomViewPager mViewPager;
                  mViewPager = (CustomViewPager) findViewById(R.id.swipePager);
                  mViewPager.setOffscreenPageLimit(0);
                  

                  在 XML 中:

                  <com.yourpackagename.CustomViewPager 
                      xmlns:android="http://schemas.android.com/apk/res/android"
                      android:id="@+id/swipePager"
                      android:layout_width="match_parent"
                      android:layout_height="match_parent"/>
                  

                  现在一次只会加载一个页面.

                  P.S:根据问题的要求,我已经发布了 Viewpager 的解决方案.我还没有对 TabLayout 进行同样的尝试.如果我能找到任何解决方案,我会更新答案.

                  P.S: As per the question's requirement, I have posted the solution for Viewpager. I haven't tried the same with TabLayout yet. If I will find any solution for that I will update the answer.

                  在此文件中,使用了 KeyEventCompat,它可能不会被 android studio 找到,因为 KeyEnentCompat 类在 API 级别 26.0.0 中已弃用,因此您需要将 KeyEventCompat 替换为事件以获取更多详细信息,您可以查看https://developer.android.com/sdk/support_api_diff/26.0.0-alpha1/changes/android.support.v4.view.KeyEventCompat

                  In this file, KeyEventCompat is used it may not found by the android studio because KeyEnentCompat class was deprecated in API level 26.0.0 so you need to replace KeyEventCompat to event for more details you can view https://developer.android.com/sdk/support_api_diff/26.0.0-alpha1/changes/android.support.v4.view.KeyEventCompat

                  这篇关于如何让我的 ViewPager 一次只加载一个页面,即 setOffscreenPageLimit(0);的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在片段中显示片段查看器 下一篇:您如何获取 Android 版 ViewPager 的当前页码?

                  相关文章

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

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