I am creating application which will support Android 2.2 to Android 4.1. The TabHost is deprecated in Android version 3.2. But the created application supported in all the versions. But I want to create the Tab bar application which will look like a tab bar in Android 4.1 while running the application in Android 4.2, If I am running the application in below android 3.2 version device, it must look like the tab bar in that device. How can I do this.?
There are many points to your question,
TabHost is not deprecated yet. Recently Google deprecated TabActivity and ActivityGroup.
Even if it deprecated, it doesn't mean it can't be used. If X is deprecated, it only means a better alternative named Y is there.
Now to answer your question, You have more than one options
You can use ActionBarSherlock as other answers suggests. (EDIT : ActionBarSherlock is now deprecated.)
You can use TabHost with fragments, See my answer here for a
good example. To use Fragment in pre 3.0 API's you need to use
Google's support library.
Try out ActionBarSherlock.
ActionBarSherlock is an extension of the support library designed to facilitate the use of the action bar design pattern across all versions of Android with a single API.
The library will automatically use the native action bar when appropriate or will automatically wrap a custom implementation around your layouts. This allows you to easily develop an application with an action bar for every version of Android from 2.x and up.
Tutorials:
tutorial 1 , tutorial 2 ,
tutorial 3
Just to add, Android has introduced ActionBarCompat to ensure ActionBar is compatible with OS below 3.0 down to 2.1. You can use ActionBarCompat in the support library instead of ActionBarSherlock
http://android-developers.blogspot.co.uk/2013/08/actionbarcompat-and-io-2013-app-source.html
Related
I have been using actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS); in my app but the target device is android 2.3.2 and does not support this code.
Is there any solution to have actionbar and tabview in android 2.3?
The solution for getting using the ActionBar in versions prior to 3.0 is called ActionBarSherlock, and enables you to give the user a unified experience across the Android versions.
Link to the website: ActionBarSherlock.com
There's actually also something called ActionBarCompat (read more here), but it's really inferior to ActionBarSherlock.
Edit: You'll find a lot of useful samples within the project hierarchy, but this should probably be the thing you're looking to accomplish: TabNavigation.java
Use ActionbarSherlock: http://actionbarsherlock.com/
Here is the tutorial for using tabs with ActionbarSherlock : http://www.androidbegin.com/tutorial/implementing-actionbarsherlock-fragment-tabs-in-android/
Yeah ActionbarSherlock is a best way to do it.
Here is how to add it link
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
I'm new to android and I'm trying to use ActionBar.I've read the documentation where it simply states that if you use android greater that 3.0 (i think) you use it by default.I've also downloaded some sample code and built it,and while it runs as it should run (meaning that the actionBar appears).In order to run it i had to import another project so that it could compile correctly.Do you know how i can effectively use the actionBar API ?
ActionBarSherlock at http://actionbarsherlock.com is an Android library for implementing the action bar design pattern using the native ActionBar on 3.0+ and a third-party library on pre-3.0.
If you want example check this
I want to develop a new Android app. Design guidelines for Droid 3.0+ encourage the use of fragments to create a UI that better utilizes tablets' screen space. Also, from Droid 3.0+ I have read that a menu bar should exist on every activity that has a menu instead of using the plain old menu key
These features are supported by SDK 11+, but I want to support SDK 8 as minimum SDK in order to achieve best market share (see here).
How can I achieve both of my objectives?
You have two possibilities:
Google provide support library for developing apps with using fragments and action bars with support of old android versions.
There is great tool Action Bar Sherlock.
Can i use Fragments in 2.2 version of the Android (Froyo) using the compatibility package ?
I want to use two nested Tabs which on clicking should display related content in the Fragments.
Have a look at ActionbarSherlock. Short description from their website:
ActionBarSherlock is an extension of the compatibility library designed to facilitate the use of the action bar design pattern across all versions of Android with a single API.
With one API you can use all that 3.0 stuff on pre-3.0 devices. (It looks the same and behaves the same)
Yes you can. Tabs are not supported in the ActionBar by the compatibility library.