Jameson
Jameson

Reputation: 4266

ViewPager not compatible with APIs 11+?

I'm building a basic app for Android (and am new to anything but iOS), and I'm only targeting APIs 15-22, so I've been using the main library in comparison to the support library for things like fragments (that is, importing android.app.Fragment as opposed to android.support.v4.app.Fragment). However, it seems ViewPager requires the fragments to be from the support library, so either I need to edit all my code to use the support library or I can't use ViewPager. I can't help but feel that think this reflects really poorly on Android as an OS. Is there any way around this? Is there any harm in using the support library for newer APIs (15-22)?

Thank you.

Upvotes: 0

Views: 586

Answers (1)

tyczj
tyczj

Reputation: 73721

However, it seems ViewPager requires the fragments to be from the support library, so either I need to edit all my code to use the support library or I can't use ViewPager

this is correct, viewpager is made to be used with the support library fragment class and not android.app.Fragment.

There is no harm in using the support library, in fact its recommended you use the support library stuff as it is updated more often and provides a more consistent experience with older devices

Upvotes: 2

Related Questions