如果ViewPager.visibility为GONE,是否将调用ViewPager适配器的InstantiateItem? [英] Will ViewPager Adapter's instantiateItem will be called if ViewPager.visibility is GONE?
问题描述
我有一个具有以下布局的活动:
I have an activity with the following layout:
LinearLayout (orientation vertical)
--> ViewPager
--> ListView
在初始加载活动时, ViewPager
尽管已创建并设置了其适配器,但可见性设置为消失。此时,当布局膨胀时,是否调用 PagerAdapter
的 instantiateItem()
吗? (因为它的可见性已消失)
On initial load of the the activity the ViewPager
visibility is set to be GONE though its adapter is created and set. At this point while the layout is inflated will PagerAdapter
's instantiateItem()
be called or not? (because its visibility is GONE)
推荐答案
我测试了该流程,发现即使放大了ViewPager视图并将适配器设置为视图,如果将viewpager设为GONE,则不会调用InstantiateItem。几秒钟后,我使用计时器验证了此操作,以将Viewpager的可见性从GONE转换为VISIBLE,发现程序流立即更改了可见性,立即输入了InstantiateItem。 (以前没有)
I tested the flow and found that even after inflating the ViewPager view and setting the adapter for the view, if the viewpager is made GONE then instantiateItem is not called. I verified this using timer to invert the viewpager's visibility from GONE to VISIBLE after a few secs and found program flow enter the instantiateItem right immediately the visibility is changed. (perviously it didnt)
这篇关于如果ViewPager.visibility为GONE,是否将调用ViewPager适配器的InstantiateItem?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!