I am developing an android application that must run on Android 2.3.3 onwards. Is it possible to use fragments on this application since fragments are not supported on pre honeycomb versions? If possible how?
Use fragment V4
android-support-v4.jar available in ref-lib folder
if not available add from
../android-sdks/extras/android-support-v4.jar
Extents fragment and import android.support.v4.Fragment
write to code**
hope it helps...
use support Library Actionbarsherlock or Support Library .. Support Library tutorial
Related
I want to implement the android navigation drawer for my app that is supporting jellybean and higher. All tutorials I seen so far use the support version.
I am wondering, are they doing that to support people who want to support old android versions?
If possible I want to use the non-support version. Does anyone know where I can find a good tutorial for that?
Or is using the support version the only way to get it?
http://www.androidhive.info/2013/11/android-sliding-menu-using-navigation-drawer/
Thanks
The docs for the Support Library states:
The Android Support Library package is a set of code libraries that
provide backward-compatible versions of Android framework APIs as well
as features that are only available through the library APIs.
This means that this library contains components, which are not included in the Android SDK. F.e. the ViewPager and related classes like the family of PagerAdapters or even the DrawerLayout.
I am implementing fragments with a DrawerLayout. I have 2 options when I import Fragments
android.support.v4.app
android.app
Which one should I use ? I dont see any difference except it seems like the android.support.v4.app has no support for objectAnimator.
What do you suggest ?
Edit: I only plan on supporting API level 14 and higher...
It depends on whether you are using Support Library.
If you are using fragments below api level 11 then use android.support.v4.app. In this case you will extend FragmentActivity which is the base class of support based fragments.
If you are using fragments in api level 11 and above use android.app. In this case you will extend standard Activity.
Take a look at the below link and decide on what versions your app should run. Depending on that decide whether you need support library or not.
https://developer.android.com/about/dashboards/index.html
I only plan on supporting API level 14 and higher...
Then there is no need to use support library. Use
import android.app.Fragment
and extend standard Activity.
If you are using support libary for drawerlayout then you should use android.support.v4.app for fragments.
You can use open-source "AndroidX" Support Library nowadays.
You can start from here AndroidX
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 :)
Anyone have a working example of fragment tabs that works on Android 2.2 and support up to ICS? Every example out there don't seem to be working even after adding the compatibility packages.
There is an example using an Activity with a TabHost and Fragments inside the tabs. It uses the compatibility library and works with current and older versions of Android.
If you installed the support library and the samples with your Android SDK you will have it on your disk already:
/extras/android/compatibility/samples/Support4Demos/src/com/example/android/supportv4/app/FragmentTabs.java
http://developer.android.com/reference/android/app/TabActivity.html
Look FragmentsTabs and FragmentTabsPager examples of ActionBarSherlock library.
Tested by me on Android 2.3 and 4.1. It works nicely and is completely reusable.
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.