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 9267513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:34:04+00:00 2026-06-18T14:34:04+00:00

As an example, see the following tutorial on how my tabs are setup initially.

  • 0

As an example, see the following tutorial on how my tabs are setup initially.

Instead of a normal activity running on one of the tabs, I want another TabActivity. So what I’m trying to do is run a TabActivity within a TabActivity. I believe the issue is that the ID’s conflict. I have tried to solve this by changing the ID’s on the secondary activity’s xml file and calling those manually in the activity, but have had no luck.

I have been searching for hours for a solution for this, but have come up with nothing.

  • 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-18T14:34:05+00:00Added an answer on June 18, 2026 at 2:34 pm

    Multiple tab activities with an application is possible.

    For instance:
    App contains a Launcher TabActivity (HomeTabActivity) with two tabs : Tab 1 and Tab 2

    Tab 1 can be a TabActivity with two or more tabs.
    Tab 2 can be a TabActivity with two or more tabs. 
    
    FirstTab, SecondTab, ThirdTab and FourthTab are simple activities actings as child for child of HomeTabActivity.
    
    xml files containing TabHost as parent element
    1. hometab.xml
    2. tab1.xml
    3. tab2.xml
    
    To differentiate between HomeTabActivity and Its child TabActivities i.e Tab1 and Tab2 
    I have put TabWidget at top for HomeTabActivity and at bottom for Tab1 and Tab2.
    

    HomeTabActivity (Very First Main Tab Activity):

    public class HomeTabActivity extends TabActivity 
    {
        private TabHost mTabHost = null;
        private Intent mIntent = null;
        private TabHost.TabSpec mTabSpec = null;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.hometab); 
            initializeTabs();
        }
    
        private void initializeTabs() {
            mTabHost = getTabHost();
    
            mIntent = new Intent().setClass(this, Tab1.class);
            mTabSpec = mTabHost
                    .newTabSpec("Tab1")
                    .setIndicator("Tab1",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);
    
            mIntent = new Intent().setClass(this, Tab2.class);
            mTabSpec = mTabHost
                    .newTabSpec("Tab2")
                    .setIndicator("Tab2",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);
    
            mTabHost.setCurrentTab(0);
        }
    
    }
    

    Tab1 (TabActivity Embedded inside the HomeTabActivity) :

    public class Tab1 extends TabActivity 
    {
        private TabHost mTabHost = null;
        private Intent mIntent = null;
        private TabHost.TabSpec mTabSpec = null;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.tab1);
            initializeTabs();
        }
    
        private void initializeTabs() {
            mTabHost = getTabHost();
            mIntent = new Intent().setClass(this, FirstTab.class);
    
            mTabSpec = mTabHost
                    .newTabSpec("Tab1 Child 1")
                    .setIndicator("Tab1 Child 1",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);
    
            mIntent = new Intent().setClass(this, SecondTab.class);
            mTabSpec = mTabHost
                    .newTabSpec("Tab1 Child 2")
                    .setIndicator("Tab1 Child 2",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);
            mTabHost.setCurrentTab(0);
        }
    }
    

    Tab2 (Another TabActivity Embedded inside the HomeTabActivity) :

    public class Tab2 extends TabActivity 
    {
        private TabHost mTabHost = null;
        private Intent mIntent = null;
        private TabHost.TabSpec mTabSpec = null;
    
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.tab2);
            initializeTabs();
        }
    
        private void initializeTabs() {
            mTabHost = getTabHost();
            mIntent = new Intent().setClass(this, ThirdTab.class);
    
            mTabSpec = mTabHost
                    .newTabSpec("Tab2 Child 1")
                    .setIndicator("Tab2 Child 1",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);
    
            mIntent = new Intent().setClass(this, FourthTab.class);
            mTabSpec = mTabHost
                    .newTabSpec("Tab2 Child 2")
                    .setIndicator("Tab2 Child 2",
                            getResources().getDrawable(R.drawable.ic_launcher))
                    .setContent(mIntent);
            mTabHost.addTab(mTabSpec);
            mTabHost.setCurrentTab(1);
        }
    }
    

    hometab.xml

    <?xml version="1.0" encoding="utf-8"?>
    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent" >
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
    
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" >
            </TabWidget>
    
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" >
            </FrameLayout>
        </LinearLayout>
    
    </TabHost>
    

    tab1.xml and tab2.xml

    <?xml version="1.0" encoding="utf-8"?>
    <TabHost xmlns:android="http://schemas.android.com/apk/res/android"
        android:id="@android:id/tabhost"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical" >
    
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical" >
    
            <FrameLayout
                android:id="@android:id/tabcontent"
                android:layout_width="match_parent"
                android:layout_height="match_parent" 
                android:background="@color/androidblue"
                android:layout_weight="1">
            </FrameLayout>
    
            <TabWidget
                android:id="@android:id/tabs"
                android:layout_width="match_parent"
                android:layout_height="wrap_content" 
                android:layout_weight="0">
            </TabWidget>
        </LinearLayout>
    
    </TabHost>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am going over a Python tutorial the one where the following example is
I have a question on the stream behavior, see the following example. What I
Please see following examples first, and which one is better? Could you compare some
Reading through the pthread tutorial from LLNL I hit the following example code /******************************************************************************
I'm trying to adapt the following example: http://docs.oracle.com/javase/tutorial/uiswing/examples/zipfiles/components-ScrollDemoProject.zip The purpose of i want to
I am reading tutorial book now. When I see an example, I get some
The following example appears in the MATLAB tutorial: X = [16 2 13; 5
Take the following article for example: http://weblogs.asp.net/psteele/archive/2009/11/23/use-dependency-injection-to-simplify-application-settings.aspx?utm_source=feedburner&utm_medium=feed&utm_campaign=Feed%3A+dotnetmvp+%28Patrick+Steele%27s+.NET+Blog%29 I don't see what benefit there is
See example: <!DOCTYPE html> <html> <head> <title>language</title> <script type=text/javascript src=http://www.google.com/jsapi> </script> </head> <body> <div
Every example I see seems to be for recursively getting files in subdirectories uses

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.