Reputation: 2272
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!
Upvotes: 0
Views: 548
Reputation: 53
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
Upvotes: 1
Reputation: 81
I was having a similar problem and the solution was to add the jar file to the libs directory AND add it to the build path in the projects properties. Do not add the file as an external jar, click "add jar".
Hope this helps.
Upvotes: 0