Search code examples
androidandroid-viewpagerandroid-tabhost

Android using viewPager vs using tabhost


In my Android application I have had to use a tab layout and I want to choose a one from folowing scenarios. they are

  • using viewPager
  • using tab host

what are the advantages of viewPager over tabhost. Which one is better. And I'm targeting the android 4.2. Thank You!


Solution

  • It actually depends on what you want and the type of content you are putting in application.

    ViewPager:

    It is supported in lower API with support library and Sherlock library is always there. Using ViewPager will give a fresh and distinctive feel to the app. For this you'll need to use fragments. Which are complicated but great in terms of performance and are replacable(a superb feature).

    ViewPager

    TabHost:

    This is achievable using both Fragments and Activities. Although in favour of FragmentTabHost, TabActivity has been deprecated. However if you are not experienced with Fragments, use Activities, but you can always migrate to fragments later. FragmentTabHost

    You should check out different tutorials and implement both of them, then decide. You should learn fragments if you embark on using ViewPager. For which, Check this

    This blog has numerous examples of tabs. It can help you decide.