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 )
How to implement tabs now that TabActivity is deprecated [duplicate]
Asked Answered
There is inbuilt example you can create new application with. (Must using updated ADT) –
Tonsure
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
Cheers, I've spent quite a bit of time trying to add the compatibility layer, but now seem stuck with this issue: code.google.com/p/android/issues/detail?id=27490 I am running r20 on OSX Lion, does anyone know if this issue has eventually been fixed. Eclipse UI 'sees' the jar files as binary files and the import line in my code does compile as the libraries java files are not recognised. –
Sabol
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.
Create include Linearlayout with small images and implement interface with navigation to this images(tabs),
public interface Tabs {
public void moveToTab1();
public void moveToTab2();
public void moveToTab3();
public void moveToTab4();
}
public Activity implements Tabs {
public void moveToTab1() {
startActivity();
finish();
}
}
// other methods
can you please elaborate your code more? i.e. How to implement images with the methods you had defined above? –
Na
© 2022 - 2024 — McMap. All rights reserved.