Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7723853
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T04:32:47+00:00 2026-06-01T04:32:47+00:00

I am creating an app that has three tabs on the main screen. Each

  • 0

I am creating an app that has three tabs on the main screen. Each of the tabs I have the content set as separate Activities. The reason I used activities instead of Fragments is because inside one of the tabs I need to be able to have Fragments and nested Fragments are not supported.

At first, I was extending TabActivity to do so, but then I realized that it is deprecated so then I started looking around. I found someone suggested using a ActivityGroup here, but… that too is deprecated.

It seems all the solutions on StackExchange to the problem I am having, contain deprecated functionality. Such as, Android: TabHost without TabActivity , and Android – Tabhost working in Activity class

What is the correct way to have a TabHost and allow the tabs to contain Fragments without using deprecated functionality?

Below is what I currently have

import android.app.ActivityGroup;
import android.content.Intent;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.TabHost.TabSpec;

public class HomeTabs extends ActivityGroup {

    @Override
    public void onCreate(Bundle savedInstanceState) {

        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        TabHost host = (TabHost)findViewById(android.R.id.tabhost);
        LocalActivityManager mlam = new LocalActivityManager(this, false);
        mlam.dispatchCreate(savedInstanceState);
        host.setup(mlam);

        TabSpec spec = host.newTabSpec("Home");
        spec.setContent(new Intent(this, HomeActivity.class));
        spec.setIndicator("Home");
        host.addTab(spec);

        spec = host.newTabSpec("Browse");
        spec.setContent(new Intent(this, BrowseActivity.class));
        spec.setIndicator("Browse");
        host.addTab(spec);

        spec = host.newTabSpec("About");
        spec.setContent(new Intent(this, AboutActivity.class));
        spec.setIndicator("About");
        host.addTab(spec);
    }
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T04:32:48+00:00Added an answer on June 1, 2026 at 4:32 am

    What is the correct way to have a TabHost and allow the tabs to contain Fragments without using deprecated functionality?

    Put views in the tabs, whether statically in the layout as immediate children of the FrameLayout inside the TabHost, or dynamically via the variant of setContent() that takes a TabContentFactory. Those views can, AFAIK, take things that manage fragments (e.g., ViewPager), or possibly fragments directly themselves via <fragment> elements.

    Or, don’t use TabHost. Use tabs in the action bar, using ActionBarSherlock for backwards compatibility. Or, use a ViewPager. Or, use a ViewFlipper and a TabWidget (which, despite the docs, does not appear to have an actual dependency on TabHost). Or, use a ViewFlipper and some other control mechanism to switch between “tabs”.

    Or, get rid of your “fragment within the tab content”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating android app that has table layout for the main activity, and that
I have a django app that has a horizontal navigation. For some reason I
I'm creating a MonoTouch app that has some declarative business logic that the client
I am creating a custom membership provider for a web app that already has
I'm creating and app that will rely on a database, and I have all
I have an app that has a UINavigationController that pushes a UITabBarController into view.
I'm creating an app that has a master-detail interface, similar to iTunes. It has
I am creating an iOS web app that has a fixed div (say 200px
We are creating an app for a client that has hundreds of megabytes of
I am creating an app that will require authentication which I have already gotten

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.