i'm implementing viewpager in my app, it has 4 tabs. In the last tab i want to implement settings. If i look at the preferencefragment its not supported for devices below API 11. Even in android compat lib v7 also, this feature is not included. Looked at few alternatives like 3rd party libs which are not official. What is the best, efficient way to use this?
Related
I am creating a new application and will have to deal with ActionBar. I know that I have to extend the AppCompatActivity because the ActionBarActivity is deprecated, however I still do not understand why I have to use the support.v7.widget Toolbar rather than the android.widget Toolbar even though I am using the latest API ?
Thank you
EDIT1:
I understand now that the support.v7.widgets are there to enable devices with old APIs to comprehend what are the new functionalities added in the newer versions and mimic them in their own way. Is that correct ?
If that is correct and I do not want to have any sort of backwards compatibility does this mean I can move forward and use the android.widget Toolbar ?
Also using the android.widget Fragment unfortunately I can not add it to a ViewPager. Why is that ? Why does it force me to use an older version which has been extended to mimic the behaviour of the new implementation of the component ?
I think I just getting lost in all of those "support" libraries. Can someone briefly ( or not ) explain all that - why are there things in the support libraries that are not included or updated in the newer versions of the API ?
Thank you
First of all you are asking Good Question, Android will add advanced features continuously in different API levels but those features are available from which level of API they are added
For Example: Consider android fragment functionality was added in API level 11 that means it will work for API level 11 and above but your application need for API level 10 devices also at that time it wont be work. For this reason android develop support library for cover a wide range of Android devices (support for low level API) to work those functionality.
Android always recommend developers to use support library for development for more information check here
Support.V7.widgets and widgets.android both are different libraries.
support.v7.widgets uses design library.
toolbar actually not an actionbar we are manually implementing a
ActionBar with support library.
And there are lot more new inbuilt properties are included like observableScrollActivity and More material designs...,
Why we aren't using default actionbar?
Because ActionBarActivity is depricated. Comparing old actionbar with our latest sdk actionbar it gives good look.
.setSupportActionBar(toolbar);
After Setting support to the toolbar gives actionbar properties to the toolbar like we can hide it by getSupportActionBar().hide();
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 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?
I'm planning an Android app that should make use of lots of UI features that later SDK versions bring with them incl. ActionBar, ActionBar.Tabs, Swipe navigation and use of Fragments (with replace, add, FragmentTransaction etc). The app should support SDK 8 (2.2) and later.
I'm a 'bit' at a loss here on how to set this up: will I be able to use all these features with the official Android compatibility library? Or will I have to use ActionBarSherlock? Will ABS give me advantages/ be easier to implement compared to the official comp. library?
Can I use the Eclipse/ ADT navigation templates with those two librarys? Can I use them alongside each other or do I have to comit to one of them?
Lot's of questions, I know :)
will I be able to use all these features with the official Android compatibility library?
No.
Or will I have to use ActionBarSherlock?
Yes.
Will ABS give me advantages/ be easier to implement compared to the official comp. library?
It will give you a backwards-compatible action bar. The Android Support Library does not.
Can I use the Eclipse/ ADT navigation templates with those two librarys?
You can do whatever you want. You will need to replace some stuff generated by those templates.
I think using using ActionBarSherlock is the best.
Have a look at this link
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.