1

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.

4

2 回答 2

14

我意识到你可以使用

viewPager.setOffscreenPageLimit(items.size());

将所有项目预加载在内存中并避免滚动时的“冻结/滞后”性能,。

于 2012-07-23T14:29:19.577 回答
1

您应该考虑Fragments通过提供一些方法来重用 ViewPager 中的现有片段并使用新数据填充或刷新它的 UI 来重用。

于 2015-03-12T15:34:18.427 回答