1

I am building an android application for Ice Cream Sandwich. I want in my application to be able to use the ViewPager, but I can't seem to do that because it says it is only available when using the compatibility package. Here I have a problem, because I don't want to use the compatibility package because if I do that I wont be able to use PreferencesFragment (it is not available within the compatibility package, but is very important for my application). Now I feel like I'm stuck. My question is, does someone knows some kind of workaround i can use, to be able to use this ViewPager or sth similar to it. And maybe if they made it available in the ice cream sandwich.. I would appreciate any suggestion. Thx!

Sandra
  • 4,239
  • 10
  • 47
  • 80

1 Answers1

2

You can use it. Add compatibility, use ViewPager.

Do not use FragmentPagerAdapter or FragmentStatePagerAdapter, cause they expect fragments from compatibility package.

Extend PagerAdapter or simply copy one of the FragmentPagerAdapter or FragmentStatePagerAdapter and use inside them fragments from ice cream.

Source links https://github.com/android/platform_frameworks_support/blob/master/v13/java/android/support/v13/app/FragmentPagerAdapter.java https://github.com/android/platform_frameworks_support/blob/master/v13/java/android/support/v13/app/FragmentStatePagerAdapter.java

logcat
  • 3,435
  • 1
  • 29
  • 44
  • Thank u. I will definitely try it out. It did not occur to me that I can check the source and do something with that. Thx very much! – Sandra Jun 07 '12 at 09:10