Right now I'm using the ViewPagerIndicator for swipe-able fragments with an indicator in my program and it's working like a charm. But since Google is pushing more and more into the direction of Fragments without using the Android support library and e.g. PreferenceFragments aren't available in the support library, I'm wondering if there is something similar to the ViewPagerIndicator that's using the standard Android library.
Google is pushing more and more into the direction of Fragments without using the Android support library
And your proof of this is... what, exactly?
e.g. PreferenceFragments aren't available in the support library
It is not possible to backport PreferenceFragment very easily, as there are many other requirements to make that useful (e.g., backporting the new PreferenceActvity). I have personally looked into backporting the preference fragment system and concluded that it would be significantly more pain than it is worth to me.
I'm wondering if there is something similar to the ViewPageIndicator that's using the standard Android library
By definition, that is impossible, as ViewPager is in the Android Support package, which means any indicator for ViewPager must use the Android Support package.
However, there is nothing about ViewPager that requires you to use fragments. You are welcome to create your own PagerAdapter implementation that does not use any fragments, or uses native API Level 11 fragments, if you so choose.
Related
I'd like to add a sliding drawer to my app which is using the min sdk version of 16 and a target sdk of 21 and should allow it to use the most recent features of the platform.
I looked around on how to implement a sliding drawer, and all the articles I found talk about using some support APIs to do just that.
My app is not yet using these support APIs.
I wonder if implementing the sliding drawer is possible without any support APIs, and if so, if there is any resources showing just that.
DrawerLayout, the basis for Creating a Navigation Drawer is only found in the Android Support Library (along with many other Support Library only APIs). There is nothing in the Android framework that provides this same functionality.
To provide the most consistent experience to users, you should just use the Support Library.
You should consider using support APIs, but if you really dont want to, you can use user-created library.
Here's one I used for one of my projects:
https://github.com/mikepenz/MaterialDrawer
Yes, it is always possible. However, the DrawerLayout class is available only in support libraries.
When I first realized that, it made no sense to me. But now I see support libraries as an extension of the core libraries (android.*).
Anyway, I recommend using the support libraries or you will have to create the logic to do exactly the same from scratch.
You can use android design support library, it's working on all devices in android and it's open source so you can edit it as you like with custom element.
Here's a reference how to implement Navigation drawer using new android support library
I think I'm missing something, but don't really understand the reasoning behind the support packages for objects like ViewPager and Fragment etc and how do I know which one to use?
I'm writing an app with min sdk 16, why are the objects not included somewhere in the API without the "support.v4" (some appear to be support v.13) qualification?
Can somebody shed a bit of light?
The support library is for the following reason:
for backwards compatibility
for functionality that is not included in the standard SDK's such as ViewPager
Here, ViewPager isn't included in the standard SDK. So, if you want to use Viewpager API then you have to use support library.
Fragment in the support library is mainly for backwards compatibility. If you are implementing something using support library which required to use Fragment then you will need to use Fragment from support library.
I have a library of Android code that I use throughout my Android projects. I created it a while back, and it uses the v4 support library (any Fragment subclasses inherit its Fragment, and all my Activitys are FragmentActivitys).
In most of my projects I have a BaseActivity class that inherits from FragmentActivity so that I don't have to worry about accidentally defining a non-support library Activity and try to use one of the Fragments from the support library. I put a lot of my application specific boilerplate in this BaseActivity.
I'm now working out the logistics of dropping support for one of my apps for devices below ICS. I have found a few issues regarding how to continue to use my Android library, which mostly boil down to whether I should continue to use FragmentActivity and the support library's Fragment even after dropping support for HC-.
I'm stuck between the convenience of "native Fragment and ActionBar and the new capabilities they come with, and the backwards compatible nature of the support library (eg, nested fragments for 4.0-4.1).
Anyone have any input as to whether I should keep using the support library, or if it's worth it to find some way to have a ridiculous amount of version checking and code overhead to provide implementations for versions that needs the support library and versions that can use the current API?
I would suggest keeping the support library implementations. This allows you use things like ViewPagers without worrying or mixing and matching implementations. It also ensures that the underlying code won't change on you until you update the support library jar.
I have a question regarding the Android Support Libraries, Fragments, and as a specific example, the ViewPager class. My intention is to create an app with similar functionality to the sample provided on the Android Developer website (http://developer.android.com/training/animation/screen-slide.html or http://developer.android.com/training/implementing-navigation/lateral.html). Looking into their code, I've noticed they utilize the android.support.v4.app library, which from my research is the only way to access the ViewPager class.
In my situation, I have no interest in backward compatibility. The minimum API level is 14 (Ice Cream Sandwich) and the build target is 4.2 Jelly Bean. In it's simplest form, my app performs exactly as does the second demo I linked on the Android dev website - just swiping between three tabs with content in each.
All of the articles/posts/answers I've read seem to heavily favor the v4 support library. Now for my, albeit long-winded, question(s):
What's the best way to structure my application - using android.support.v4.app, and thereby using SupportFragments, or to use the Fragments provided in android.app - and why?
If Fragments from android.app are the way to go, what is the optimal way to approach ViewPagers?
If SupportFragments are best-suited to the task, I would estimate that they possess the same functionality as the other - so what's the purpose of having them at all inside android.app?
Hopefully someone with a clearer understanding can give me a bit of clarification because I'm boggled...
You can use ViewPager with native fragments from the android.app package with the adapters from the android.support.v13.app package. You have to use the v13 support jar for that.
There are two versions of the adapters that work with ViewPager, the ones in the v4 package are meant to be used with support fragments, the ones in v13 with native fragments.
The reason why there are now two fragment implementations is historical: Fragments in the android.app package were introduced with Android 3 for tablets only and the support library was created to bring fragments to phones running older versions. On Android 4 you have both.
From my own experience I would recommend using support fragments, even when developing for Android 4. Here are some reasons: Fragment or Support Fragment?
android.app.Fragment class is deprecated since Android P (link), so only android.support.v4.app.Fragment should be used everywhere.
If you're going to target API 11+, you won't need the support library [and your actual apk will be smaller, at least).
If you want to support anything before Android 3.x, you'll need the support library.
Is this what you're asking?
"The type TabActivity is deprecated"?
I am making the Tabs of app following tutorial book.
I've checked from the android developer.com website, but i have no ideas on the significance of the following message : This class is deprecated.
New applications should use Fragments instead of this class; to continue to run on older devices, you can use the v4 support library which provides a version of the Fragment API that is compatible down to DONUT."* (http://developer.android.com/reference/android/app/TabActivity.html)
What is v4 support library?
How to finish the tab functions?
You can still use a deprecated package. It is however recommended to use Fragments, and thus the support package. You can read more about it here. However, if you are a beginner at java and android development, I would recommend ignoring the deprecation for now and come back to this when you have completed the tutorial you are currently using if you find it educating.
If you want to watch a nice example of tabbed navigation using Fragments, then create a new project in Eclipse using android 4.0 or later. Make sure your android-plugin is updated. You will get the option to create a project with basic navigation already implemented.
"Deprecated" means that the api developers don't recommend using it anymore, probably because its not a good model, or inefficient, etc. Fragments were introduced in Honeycomb and can be used to provide a similar functionality as tabs and is more in-line with android's current design philosophy.
Since Fragment was introduced in Android 3.0 Honeycomb, you might think you cannot use that for pre-Honeycomb devices. Enter Support Libraries. They are libraries which you can include in your application which needs to run on pre-Honeycomb and still use this class.
So if you want to, you can finish the TabActivity as described in whatever tutorial you are following, it'll probably work on a few more upcoming android versions. But it is recommended that you start using Fragments.