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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T01:17:23+00:00 2026-05-23T01:17:23+00:00

Edited for a little clarity So … I must be misunderstanding how to properly

  • 0

Edited for a little clarity
So … I must be misunderstanding how to properly use TabHosts, because my code crashes completely during setup when I try to add some TabSpecs.. I would like to have a view that has some UI interface with graphics associated with it and animations, and then a menu system that uses a tab setup. My code looks something along the lines of:

public void myView extends RelativeLayout {

    // Other Views ...
    private TabHost myTabHost;
    private ExpandableListView listView1; // content for tab 1
    private ExpandableListView listView2; // content for tab 2

    public myView(Context context) {
        super(context);

        // some other stuff
        myTabHost = new TabHost(context);
        myTabHost.setId(R.id.myTabHost);

        listView1 = new ExpandableListView(context);
        listView1.setId(R.id.myExpandableListView1);

        listView2 = new ExpandableListView(context);
        listView2.setId(R.id.myExpandableListView2);

        TabSpec tab1 = myTabHost.getTabSpec(res.getString(R.string.tab1));
        tab1.setIndicator(res.getString(R.string.tab1), res.getDrawable(R.drawable.tab1));
        tab1.setContent(R.id.myExpandableListView1); // *********
        myTabHost.addTab(tab1);

        // do something similar for tab2..
    }

}

Here’s the Activity I’m currently using..

public void myActivity extends Activity {

    @Override
    public void onCreate(Bundle savedState) {
        super.onCreate(savedState);

        // do a little stuff..

        TabHost myTabHost = (TabHost) findViewById(R.id.myTabHost); // not sure if I'm supposed to set up the tabs in my activity, or not..
        // I tried it after it crashing in the view, and it still crashed in the activity..
        ExpandableListView myListView1 = (ExpandableListView) findViewById(R.id.myExpandableListView1);
        // set up expandable list view the way I want from data sources..

        // do something similar for myListView2
    }

}

From what I understand, I don’t want to extend TabActivity because that assumes the whole screen is going to be one giant TabHost, right? I only want the TabHost to be a small portion of the Activity… The problem is that the system crashes where I have indicated by the *********‘s.. I guess I just don’t understand properly how to go about setting up the tabs? Could someone please enlighten me as to the proper way to do it, or maybe suggest why it’s crashing? I guess I should also add the question .. to use a TabHost, do I HAVE to use a TabActivity? (I don’t see why I would have to, but Android can be funny that way..)

BONUS
I was poking around and found this stackoverflow link regarding tabhosts without tabactivities.. They reference a LocalActivityManager. I’ll have to read about that..

  • 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-23T01:17:24+00:00Added an answer on May 23, 2026 at 1:17 am

    I’m pretty sure that you need an Activity to use the TabHost like you want to. Also, TabHost requires a very specific layout to be present for it to work, which you don’t have either. I believe you need to rethink your approach.

    I’m pretty sure you’ve seen this, but just in case.

    Edit

    You can extend from Activity (instead of TabActivity) and place your tab widgets wherever you want. However, you MUST call tabHostVariable.setup() before you add any TabSpecs.

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

Sidebar

Related Questions

I have edited this from my real code, so that it is a little
Edited code - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @Cell;
I've installed jBPM 4.4 and it looks neat. I've edited a little example process
Edited to make my requirements a little more clear I would love to find
EDITED: Java httpPost into .asp form I am trying to understand .asp a little
Hey, I've got this nice little piece of code, much like all the other
Hi all I am trying to make a CMS in which you use little
Now, everyone knows the cute little trick where you punch this Javascript code into
I'm working on a little experimental utility to use within our company that indexes
First, a little background. I have a DataContext object (Linq to SQL). I use

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.