Will ViewPager Adapter's instantiateItem will be called if ViewPager.visibility is GONE?

廉价感情. 提交于 2019-12-08 10:24:39

问题


I have an activity with the following layout:

LinearLayout  (orientation vertical)
    --> ViewPager 
    --> ListView

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)


回答1:


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)



来源:https://stackoverflow.com/questions/11977775/will-viewpager-adapters-instantiateitem-will-be-called-if-viewpager-visibility

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!