It took quite a while searching stackoverflow and google and can not find a guide to properly explain to me how to implement Tabs in my application.
I know it should not be used TabActivity, I also read about the recommendation not to use TabHost (at least that understanding). My interest is not just changing the content is run a full activity when changing tab.
MainActivity:
- Tab1Activity
- Tab2Activity
- Tab3Activity
My goal is to build an application that is supported by a wide range of devices from api 8 to the latest. I'm using android-support-v4.jar
.
My second goal is to load in each tab an activity because at least two of them consume enough resources and speed should always prevail.
Can help me with a guide or explain a "correct" way to achieve this.
You should use Tabs with Fragments.
Look this : http://android.codeandmagic.org/2011/07/android-tabs-with-fragments/
As the other suggested, the best way to implement tabs in your application is to use fragments.
You should not use activities contained in a tabactivity, which is currently deprecated. Even the official documentation suggests to use fragments, stating that
New applications should use Fragments instead of this class
However, if you still feel retro' and you REALLY want to use tab contained activities, you need to use tabhost. A nice tutorial can be found here, but again, I strongly recommend to go for the fragment 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