gpt4 book ai didi

java - 如何在viewpager android中保留1000个动态 fragment ?

转载 作者:太空宇宙 更新时间:2023-11-04 10:26:50 25 4
gpt4 key购买 nike

我需要使用一项 Activity 来显示一千个问题和 4 个选项来填写。我有一个使用 viewpager 的想法,但无法显示 1000 个 fragment 。

最佳答案

可以使用 ViewPager 来处理 1000 个 fragment 。只需确保您的适配器扩展 FragmentStatePagerAdapter .

来自文档:

This version of the pager is more useful when there are a large number of pages, working more like a list view. When pages are not visible to the user, their entire fragment may be destroyed, only keeping the saved state of that fragment. This allows the pager to hold on to much less memory associated with each visited page as compared to FragmentPagerAdapter at the cost of potentially more overhead when switching between pages.

关于java - 如何在viewpager android中保留1000个动态 fragment ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50443504/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com