Android: TabActivity deprecated, use Fragments?

Martin picture Martin · Sep 12, 2012 · Viewed 28.4k times · Source

It appears that TabActivity is now deprecated, we need to use Fragments.

I tried using a standard Activity but couldn't call getTabHost.

So it appears i have to use Fragments. But i am a little confused how this would work.

I understand that fragments are not activities so they are not in the manifest file?

SO i presume i can't do startActivity on a fragment?

Does anyone know of a good example explaining the tabHost and Fragments, all the examples and tutorials i have found are only using the tabactivity.

Thanks in advance

Answer

ישו אוהב אותך picture ישו אוהב אותך · Jun 22, 2016

Maybe you could use TabLayout instead.

Tabs are now best implemented by leveraging the ViewPager with a custom "tab indicator" on top. Google's new TabLayout included in the support design library release for Android "M".

Visit the full tutorial of using TabLayout in Google Play Style Tabs using TabLayoutEdit PagePage History