How to correctly create a Tablayout now that the Tabactivity is deprecated?
Asked Answered
B

3

8

Since the introduction of Fragments the TabActivity is deprecated.

The Hello Views TabLayout Tutorial however still uses the TabActivity and the API-Documentation has no clear answer on how to create a Tab Layout with Fragments instead of a TabActivity.

How are you building Tablayouts now that the TabActivity is deprecated?

Bunny answered 30/9, 2011 at 6:28 Comment(1)
B
0

Since the release of ActionBarSherlock there is no need to use the old tap API. Just use the new tabs with fragments in any way you like on any recent Android Version (2.x)

Bunny answered 2/11, 2012 at 7:19 Comment(0)
W
0

Well, I had that issue and here is the solution example for that FragmentTabs.java. But I am still awaiting for the solution that Fragments provides instead of using ActivityGroup.

Wallford answered 30/9, 2011 at 6:33 Comment(0)
A
0

Use TabHost or ActionBar with tabs along with Fragments .

I recommend you to use ActionBar with tabs and a ViewPager to hold the fragments for each tabs.

in onPageSelected() of onPageChangeListener, set the current tab by getActionBar().setSelectedNavigationItem(position);

and in onTabSelected(Tab tab, FragmentTransaction ft) of TabListener set the current page in viewpager by mViewPager.setCurrentItem(tab.getPosition());

Check this example too. Good Luck!

Ander answered 2/11, 2012 at 6:7 Comment(0)
B
0

Since the release of ActionBarSherlock there is no need to use the old tap API. Just use the new tabs with fragments in any way you like on any recent Android Version (2.x)

Bunny answered 2/11, 2012 at 7:19 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.