Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to implement tabs now that TabActivity is deprecated [duplicate]

I am trying to implement some simple tabs in an activity.
I think I have the xml code ok (I am using the minimal tabHost/widget/FrameLayout found in example code), I am however having issues with the java side.
Most of the documentation on how to do this point to using TabWidget, this class is now deprecated. It is suggested that one should use fragments. But fragments seem to be used in a rather different manner.
Has someone go some sample code of how to implement in java some very basic tabs defined in an xml file now that TabHost is deprecated.(the example [here[1 does not use xml )

like image 555
user1654757 Avatar asked Sep 07 '12 13:09

user1654757


2 Answers

If you go to the Android developer guide they show you how this can be done

http://developer.android.com/reference/android/app/TabActivity.html

There is example code that shows you how to do this using fragments

like image 150
AdamM Avatar answered Sep 23 '22 18:09

AdamM


Create your tabs using fragments.

A good example: http://thepseudocoder.wordpress.com/2011/10/04/android-tabs-the-fragment-way/

And, of course, you should read about fragmentActivities in the official documentation: http://developer.android.com/reference/android/support/v4/app/FragmentActivity.html

Search for more - there are many other examples how to create tabs in this way.

like image 34
Do. Avatar answered Sep 25 '22 18:09

Do.