Android using viewPager vs using tabhost-ThrowExceptions

Exception or error:

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!

How to solve:

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


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).



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.


I found it very painful to customize tab host such as increasing indicator height, have to create 9 draw batch and customize background and many things.

With tab layout, only one line of code

So, I recommend using view pager with tab layout that provides the same UX. Tab host is not deprecated, but it will happen soon, I guess 😛

Leave a Reply

Your email address will not be published. Required fields are marked *