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 )
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
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With