Anuj
Anuj

Reputation: 398

Confused on v4 and v13 support library

I am creating a new application with min sdk verrsion=15,so i dont wanna use v4 support library.Now in my application i want to use scrolable tabs so for that i wil require view pager.Now in my xml when i am using something like this i get error

XMl code

<android.support.v13.view.ViewPager
    android:layout_height="match_parent"
    android:layout_width="match_parent"
    xmlns:android="http://schemas.android.com/apk/res/android" /> 

But this code works fine with v4 support library.

  1. Now why cant i use v13.view.pager????
  2. And if i use v4.view.pager will it coincide with other fragments as i am not using v4.support.fragments

Upvotes: 3

Views: 4299

Answers (2)

MrEngineer13
MrEngineer13

Reputation: 38856

The reason you cannot use android.support.v13.view.ViewPager is because it does not exist. If you search for ViewPager and click "Reference" on the side bar then you can tell by the documentation that ViewPager belongs to Support v4 based on its package name android.support.v4.view.ViewPager. If you look for a v13 version under android.support.v13.view then you will see that no such package exists. Conversely, there is a android.support.v7.view but it does not contain a ViewPager class.

AFAIK, there is no where in the documentation that says that ViewPager requires using fragments from the support library. I have only used them with the fragments from support v4 library but that is not to say they won't work with regular fragments.

Upvotes: 2

CommonsWare
CommonsWare

Reputation: 1006614

Now why cant i use v13.view.pager?

Because there is no such class. ViewPager is android.support.v4.view.ViewPager. It does not matter whether you are getting ViewPager from support-v4 or support-v13.

And if i use v4.view.pager will it coincide with other fragments as i am not using v4.support.fragments

Use android.support.v13.app.FragmentPagerAdapter. The support-v13 library offers v13 editions of FragmentPagerAdapter and FragmentStatePagerAdapter that work with native API Level 11+ fragments.

Upvotes: 10

Related Questions