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.?
-
1Are you sure TabHost is deprecated? [Documentation](http://developer.android.com/reference/android/widget/TabHost.html) doesn't says so. – Krishnabhadra Jan 11 '13 at 05:19
-
Hi, How many tab bars can I create using Actionbar.? If more than 10 to 15 means how can I see the last one. – Karthick Jan 11 '13 at 10:03
-
Hey TabHost is not deprecated. TabActivity got deprecated. – Prachi Jun 04 '14 at 08:12
3 Answers
There are many points to your question,
TabHost
is not deprecated yet. Recently Google deprecatedTabActivity
andActivityGroup
.- 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 useFragment
in pre 3.0 API's you need to use Google's support library.

- 34,169
- 30
- 118
- 167
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:

- 1
- 1

- 20,443
- 6
- 51
- 84
-
Yes,I have tried these samples. But i need to create an application with multiple tab views and have to load different URL's into that tab bars. – Karthick Jan 11 '13 at 05:29
-
you can do everything you said with ActionBarSherlock. You can use Fragments and TabHost as well. – Anup Cowkur Jan 11 '13 at 05:32
-
Oh.OK.How can I create application which will automatically detect the Android Version and the tab bar will be created according to the version. – Karthick Jan 11 '13 at 06:08
-
ActionBarSherlock handles this automatically. You don't need to check the version. The library will handle it for you. – Anup Cowkur Jan 11 '13 at 06:25
-
Hi, how many tab views can I create using ActionBar.? If I create more than 10 tab bars. How can I create and view those tabs one by one. – Karthick Jan 11 '13 at 10:09
-
You need to try it out yourself and see for your specific situation. No one can predict this without any code. – Anup Cowkur Jan 11 '13 at 10:34
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

- 7,835
- 5
- 38
- 71

- 1,061
- 11
- 14