Android support library v13 is supposed to provide support for newer APIs from Android 3.1. However, as far as I can tell there is no support for child fragments. Specifically, where is getChildFragmentManager()? The v13 support library relies on native fragments, which didn't add this method until API level 17. I have an app with minimum SDK level 14 so I should be able to use the v13 support library, but it seems I can't.
I don't want to go all the way back to the v4 support library and take on all it's weight. The v13 library is perfect otherwise.
If you want to use nested fragments within a native Fragment. use getFragmentManager().
If you want to use nested fragments within a support library Fragment, use getChildFragmentManager().
Just found this out by accident. It works. :)
Android support library v13 is supposed to provide support for newer APIs from Android 3.1
Not really.
However, as far as I can tell there is no support for child fragments
Correct. You cannot change existing classes from an external library in Java. android.app.Fragment already exists, therefore the library cannot add methods to Fragment.
I have an app with minimum SDK level 14 so I should be able to use the v13 support library, but it seems I can't.
You can simply not use nested fragments. Or, use the fragments backport.
I don't want to go all the way back to the v4 support library and take on all it's weight
android-support-v13.jar is larger than android-support-v4.jar.
If v13 included all of v4 then what is its purpose?
It adds some classes, like native-fragment implementations of FragmentPagerAdapter and FragmentStatePagerAdapter, that are not needed for apps who do not have native fragments, because their android:minSdkVersion is below 11.
the v13 library uses the native fragments and activities, not support fragment
android-support-v13.jar contains all of the android.support.v4 and all of the android.support.v13 classes from the SDK.
you should just use the v4 support library fragments. then you can use nested fragments w/ api 14. There is no real downside to doing so. They are already included in the v13 support library (it includes all of v4)
Related
does ics support android.app.Fragment?
Whats is the major difference between v4 vs v13 for fragments?
When android.app.Fragment support by default android.Why there is no android.app.FragmentPagerAdapter? and what is the reason it supported by v13 library?
Fragment was introduced with Honeycomb, so yes ICS supports it. It was not supported on Gingerbread or before, except via the compatibility library. And the differences between the various Fragments in different levels of the compatibility library is that some features were too hard or impossible to backport all the way to 4, so they backported them as far back as was reasonable. If you need to use those features you can use the appropriate compatibility library, you just won't be able to use the app on an older platform.
does ics support android.app.Fragment?
Yes. Fragments were introduced in API lvl 11 (Android 3.0, Honeycomb)
Whats is the major difference between v4 vs v13 for fragments?
Fragments from the support library are in v4 library and not in v13. The goals of the v4 libraries is to bring compatibility down to Android 1.6.
Why there is no android.app.FragmentAdapter?
I assume you are talking about FragmentPagerAdapter since FragmentAdapter does not exist in android or in the support library. I assume FragmentPagerAdapter was introduced after and put in support library as a late addition. It is easier to add new features in a library than putting it inside the android SDK.
what is the reason it supported by v13 library?
The lower you go in terms of compatibility the harder it is. You might lack features and have to reimplement them in order to implement your new API.
One thing to keep in mind is that support-v13 includes support-v4 as a dependency.
My new project is gonna be of API 14 min level. I'm going to use the compatibility library because it holds a lot of cool stuff. Wouldn't I bump into any compatibility issues if I use android.app.Fragment instead of android.support.v4.app.Fragment?
I don't want to use the later because I would like to use new (Honeycomb) animation framework to animate fragments transition (and to use FragmentManager from SDK), for instance. Just afraid it wouldn't work with some components from the compatibility lib where android.support.v4.app.Fragment must be used.
Wouldn't I bump into any compatibility issues if I use android.app.Fragment instead of android.support.v4.app.Fragment?
Not generally. Use the v13 version of the base library, not the v4 one, so that you can pick up v13 editions of classes like FragmentPagerAdapter, which will work with the native API Level 11+ edition of fragments.
I am trying to use nested fragments with the v13 Android support library and I am unable to call getParentFragment(). I have use the v4 support library with nested fragments and have successfully made calls to getParentFragment.
Does the v13 Android support library support nested fragments? Or, can you only use nested fragments with the v4 support library, or if the app targets API 17?
Do not use v13 unless you know it's fine for you:
This library is designed to be used for Android 3.2 (API level 13) and
higher. It adds support for the Fragment user interface pattern with
the (FragmentCompat) class and additional fragment support classes For
more information about fragments, see the Fragments developer guide.
For detailed information about the v13 Support Library APIs, see the
android.support.v13 package in the API reference.
Use v4 of support library
I had this same issue. it turned out that my child fragment extended Fragment. I changed it to extend android.support.v4.app.Fragment and it worked fine.
The new edition of my app has a minimum SDK of 14, so I thought that I could get rid of the support.v4 library that I've been using for the older version. However, it now looks like I might have to use ViewPager and thus am back to including the library.
So can I just use the ViewPager-related classes from the library and not have to use the other classes that are now native in V14, such as Fragment (and also not have to change Activity to FragmentActivity)?
I would assume that I can do this (only use ViewPager from the library) but wanted to check to make sure.
You may have to use v13 support libraries for some things. If what you want to use exists in both v4 and v13, use v13. v13 works with Fragments native to the higher APIs, while v4 only works with v4 fragments.
I just created a project that has only ViewPager and it's closest dependencies - without Fragments and without actionbar, which are supported natively as of api level 14.
https://github.com/kilaka/ViewPager-Independent
Enjoy :)
I have searched a bit around for a pager for fragment , I develop on ICS API.
I know about ViewPager and all the support libs for earlier version but i don't get why I should use a support library consider the fact that I use the lastest version of the api and don't plan to support earlier version.
Do I have to write the "ViewPager" myself or is there something i didn't see in the api.
Does the Android ICS API have a native equivalent to ViewPager support lib?
No.
I know about ViewPager and all the support libs for earlier version but i don't get why I should use a support library consider the fact that I use the lastest version of the api and don't plan to support earlier version.
The Android Support package is not only for backports of newer APIs. It is also for other classes that, for whatever reason, are not being added to the SDK, such as ViewPager and its supporting classes.
Do I have to write the "ViewPager" myself or is there something i didn't see in the api.
You are welcome to write your own implementation of a view paging component. Savvy programmers would use the one in the Android Support package, since it is already written and (mostly) debugged.
UPDATE: Note that ViewPager works just fine with pages that are:
API Level 11+ native fragments
Android Support backported fragments
arbitrary Views
For the first case, you need the v13 version of the support JAR, which contains v13 versions of the FragmentPagerAdapter and FragmentStatePagerAdapter classes.