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.
Related
I must be confused, I thought the V4 support library is supposed to help older devices to have newer API's, how come there is not equivalent ViewPager class if I do not use the V4 Support library?
The support library is not exclusively for compatibility with newer APIs. Some of the features (e.g. ViewPager, DrawerLayout, LocalBroadcastManager) are only present there.
As for "why", it's hard to say... I guess they wanted to make those widgets available independently of an Android release.
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)
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 came across the ViewPager and the related FragmentPagerAdaptor which are not part of the regular Android packages, but only available in the V4 support package. It seems I cannot use the FragmentPagerAdaptor with a android.app.Fragment since the FragmentPagerAdaptor requires a v4 FragmentManager to instantiate. Reading Difference between Activity and FragmentActivity this seems to be aligned - use either v4 Fragments and related classes or the regular android.app.Fragments. Never mix.
Taking it further, I see no need to use the regular android.app.Fragments at all since they are less powerful than the v4 support packages. (Cite from another question: 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.). The "only" downside I can think off is that the v4 support libraries is bundled with the APK which means my app will take up more space.
Am I correct to conclude that I should always use v4 support libraries for fragments since those include more functionality? (And they are backwards compatible, not to forget.)
I just realized that it is possible to use the android.app.Fragment and the android.support.v4.view.ViewPager together... If you use the android.support.v13.app.FragmentPagerAdapter... So it seems that the v13 support package solves/improves the compatibility issues between android.app.Fragment and android.support.v4.view.ViewPager. What a mess.
While this resolves the particular example I came up with, I am still wondering if the best option is to always use v4 classes when they are available instead of the build-in classes (e.g. android.app.Fragment) even if I am only worried about ICS and newer devices?
In terms of backwards compatibility, indeed using the v4 support package version is the best approach.
As the shift of devices moves towards the operating systems that have the functionality built in it will probably become easier to use the SDK version, as all of the functionality found in the support package will be included in the SDK.
For now, stick with v4 to offer support for 2.2/2.3 devices which still hold a large share of the Android device pie
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.