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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:57:13+00:00 2026-05-22T14:57:13+00:00

This should be really simple but it aint working. What I want is two

  • 0

This should be really simple but it aint working. What I want is two different tabs that use the same activity class. I don’t care if they are sharing the same activity or if they each have their own instance. In this code I set the second tab with the same activity as the first, but only the first will load in the app. If I click the second tab I get a black screen:

//Create tabs
    Resources res = getResources();
    TabHost tabHost = getTabHost();
    TabHost.TabSpec spec;
    Intent intent;
    String tabTitle = getString(R.string.livevideo);

    // Initialize intent
    // Initialize tabspec for each tab and add it to host
    intent = new Intent().setClass(this, CameraListView.class);
    spec = tabHost.newTabSpec("live").setIndicator(tabTitle,res.getDrawable(R.drawable.livebtn)).setContent(intent);
    tabHost.addTab(spec);

    tabTitle = getString(R.string.videoplayback);
    intent = new Intent().setClass(this, CameraListView.class);
    spec = tabHost.newTabSpec("playback").setIndicator(tabTitle,res.getDrawable(R.drawable.playbackbtn)).setContent(intent);
    tabHost.addTab(spec);

Can’t this just be a simple thing? I would think that making a new intent with the same activity would instantiate a second copy of the activity, but perhaps that isn’t how Android works.

  • 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-05-22T14:57:13+00:00Added an answer on May 22, 2026 at 2:57 pm

    Try something like this:

    TabHost tabHost = getTabHost();
    TabSpec spec = null;
    
    tabSpec = tabHost.newTabSpec("tabSpec");
    tabSpec.setIndicator(someString, someDrawable);
    tabSpec.setContent(new Intent(getApplicationContext(), CameraListView.class));
    tabHost.addTab(tabSpec);
    
    tabSpec = tabHost.newTabSpec("tabSpec");
    tabSpec.setIndicator(someString, someDrawable);
    tabSpec.setContent(new Intent(getApplicationContext(), CameraListView.class));
    tabHost.addTab(tabSpec);
    

    //EDIT
    In response to your question in comment. I don’t know anything about any way to do what you’re want to do. I had exactly the same problem. Finally I solved it by creating new Activity which inherited from firstTabActivity and I put it in second tab. In your case I think it’ll be quite simple – SecondTabActivity extends FirstTabActivity and overrides method onListItemClick().

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

Sidebar

Related Questions

I know this is a really simple thing that I really should know but
This should be really simple, but I have tried many solutions posted on the
This seems like it should be really simple, but I'm unable to figure this
This should be really simple but I'm a javascript/jQuery rookie, so here we go:
This should be really simple but I can't get it to work, how do
This should be really simple, but what is the way to go on this.
Ok this should be really simple, but I am doing my head in here
I know this should be really simple, but im having trouble getting this to
I'm cocking this up and it should be really simple but the value of
This is frustrating me. It should be something really simple but I can't get

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.