Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference tabActivity and tabhost and tab Layout

Tags:

android

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

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

like image 777
A.A Avatar asked Oct 20 '14 15:10

A.A


People also ask

What is a tab layout?

TabLayout provides a horizontal layout to display tabs. Population of the tabs to display is done through TabLayout. Tab instances. You create tabs via newTab() . From there you can change the tab's label or icon via TabLayout.

What are the two TabHost children?

TabHost consists of two children of which one is FrameLayout (which is used to show the contents of the activity) and another one is TabWidget.

What is the use of tab bar in Android?

A TabLayout provides a way to display tabs horizontally. When used together with a ViewPager , a TabLayout can provide a familiar interface for navigating between pages in a swipe view.


2 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

like image 75
Karakuri Avatar answered Sep 18 '22 11:09

Karakuri


Documentation about making swipe views / tabs:

http://developer.android.com/design/building-blocks/tabs.html

http://developer.android.com/training/implementing-navigation/lateral.html

TabActivity:
deprecated in API level 13

http://developer.android.com/reference/android/app/TabActivity.html

TabHost:

http://developer.android.com/reference/android/widget/TabHost.html

like image 21
Francesco verheye Avatar answered Sep 18 '22 11:09

Francesco verheye