I have a Fragment
that contains a ViewPager
, now the ViewPager
contains 3 different items , i.e each item(Page) contains a ListView
and each list hase it Own Adapter
, I cant use FragmentPagerAdapter
sine the ViewPager
lives in a Fragment
.
Should i Load all the Three ListViews
Data in the Fragment
and pass it to the PagerAdapter
?
then you can create a customer fragment extends BaseLazyFragment for example
the first time when the fragment create setUserVisibleHint() method is header than onCreateView(),so the lazyLoad() method may throw NullPointerException because the oncreateView() is not invoke, so you should to create a flag variable --> isPrepared.
reference link
Actually it depends how big is your data which are you loading?
If it is big, try to download ie. 10 items for each page and pass that data to adapters and cache it. After what, implement lazy loader (like in google play app), which downloads your next items for your correct page, not for all.
So all your three pages would have data to display on a first load, if user wants more, he can navigate to the bottom of your list, press "load more" and get more items :)
From my experience this solution works fine. Of course server side should be adopted for this kind of loader.
Also there are more considerations, ie. maybe your data is "very live". So you have to think about it.