I'm trying to use the function setOffscreenPageLimit()
in ViewPager, but Eclipse says The function setOffscreenPageLimit()
is undefined for the type ViewPager
However, I see it in the docs and in many examples. ViewPager
Here's my code:
import android.support.v4.view.ViewPager;
public class MyView {
private final ViewPager viewPager;
MyView (ViewPager viewPager) {
this.viewPager = viewPager;
viewPager.setOffscreenPageLimit(2); //<-- can't find it
}
}
I think it must be some strange problems with the library. My minSdk is 7 and target is 13. I've pressed "check for updates" many times and even tried manually re-importing the compatibility library but this function still doesn't show up. Any ideas? I really need this function!
I think that .setOffscreenPageLimit() was a recent addition to the android support library. You should update your support library to the newest (currently v9) using Android SDK Manager. Cheers