ViewPager, compatibility package and ice cream sandwich

自闭症网瘾萝莉.ら 提交于 2019-12-11 13:57:59

问题


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!


回答1:


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



来源:https://stackoverflow.com/questions/10928762/viewpager-compatibility-package-and-ice-cream-sandwich

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!