Reputation: 1786
I'm creating a android application with target on 2.2. I still want to use the ViewPager provided in the android.support-v4.jar.
I'm using a FragmentPagerAdapter in combination with Fragment to display content. Each fragment contains a WebView, displaying some html data.
Scrolling a WebView up and down works great but the swiping between pages in the ViewPager behaves very jerky and not at all as smooth as scrolling the WebView.
Is there any way you can increase the scroll performance of the ViewPager, maybe something like ConvertView from BaseAdapter?
I'm guessing I could load the url in a background thread but from what I've heard that's not best practice.
Any suggestions would be great, thanks.
Upvotes: 1
Views: 5383
Reputation: 2387
You should consider reusing the Fragments
by providing some method to reuse existing fragments in the ViewPager and populate or refresh it's UI with the new data.
Upvotes: 1
Reputation: 1786
I realized you could use the
viewPager.setOffscreenPageLimit(items.size());
to keep all items preloaded in memory and avoid the "freeze/laggy" performance while scrolling,.
Upvotes: 14