Alternative TabAcitivity

Hi friends. I want to create a tab in a project. There are two ways to create a tab, which I found

1) Extends the activity class with the TabActivity class, which is deprecated since I think this is an easy way, but not because it is deprecated, so I want to know if there is any other class or any alternative for this class.

2) Create an individual activity for each tab that is long but comfortable, but still feels that TabActivity is fast.

I was wondering if anyone can tell me, Thanks

+3
source share
2 answers

There are two ways to create a tab, which I found

You also can:

  • Use a ViewPager with a tabbed indicator, such as PagerTabStrip , TabPagerIndicator from the ViewPagerIndicator project, PagerSlidingTabStrip , etc.

  • Use the tabs on the action bar (note: they are converted to a drop-down list in some device sizes and orientations)

  • Use FragmentTabHost

  • Use TabHost and TabWidget in regular Activity

The following project examples demonstrate:

Note that the first three samples use ActionBarSherlock, so they run on Android 2.x devices. The fourth should work on anything since Android 1.0.

+3
source

Use Fragments as an alternative to TabActivity. To feel like tabs, you can do it. Use FragmentActivity . Add different fragments to it. And use ViewPager to switch between different fragments.

+2
source

Source: https://habr.com/ru/post/1447644/


All Articles