问题
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