Home » Android » android – Difference tabActivity and tabhost and tab Layout

android – Difference tabActivity and tabhost and tab Layout

Posted by: admin May 14, 2020 Leave a comment


What is difference between tabActivity and tabhost and tabLayout in Android?

My layout will have five tabs. Which one is best for this?

How to&Answers:

TabActivity is deprecated. You should use Fragments and FragmentManager instead. TabHost and TabWidget simply define a portion of the screen for tabs and tab content. There are ways to use them with a TabActivity, but it is not compulsory to do so. Note that there is now a FragmentTabHost class that you can consider as well.

If you want these tabs to actually be in the same Activity and be able to swipe between them, you can also consider using a ViewPager with a PagerTabStrip on top: https://developer.android.com/training/implementing-navigation/lateral.html


Documentation about making swipe views / tabs:



deprecated in API level 13





Try this way,hope this will help you to solve your problem

As we know Tab-Activity is now depreciated in Android, but some time we use it for create simple Tab pages in our application. So,These days we use Host Activity in android

In android there are many layouts available for a developer to represent maximum functionality with vivid User Interface (UI). Tab Layout is also one of them. In Tab Layout there are multiple tabs which holds one activity in each one tab. Simply user will get four activities on only one activity contains tabs. Current activity in Tab Layout will appear as per tab clicked. In this topic customization of Tab Layout will be covered.

Mostly we used :-

1. TabHost
2. TabWidget
3. TabHost.TabSpec
4. FrameLayout
5. Intent

You should use tabHost for creating a tabs.

You can find more from here


TabActivity is Depricated

This class was deprecated in API level 13.
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.


Container for a tabbed window view. This object holds two children: a set of tab labels that the >user clicks to select a specific tab, and a FrameLayout object that displays the contents of that >page. The individual elements are typically controlled using this container object, rather than >setting values on the child elements themselves.

Use Fragments for making the tabs

Here is a nice tutorial to get you started – Check this link – Click Here