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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T16:15:22+00:00 2026-05-30T16:15:22+00:00

I built my own TabHost with this code: I have a problem that when

  • 0

I built my own TabHost with this code:
I have a problem that when i open a new Activity from one of this TabHost’s activities so the new activity opened without the TabSelector.

public void onCreate(Bundle savedInstanceState) {
    /*super.onCreate(savedInstanceState); 
    setContentView(R.layout.main); */

    super.onCreate(savedInstanceState);
    this.requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.tabhost);
    setupTabHost();
    mTabHost.getTabWidget().setDividerDrawable(R.drawable.tab_divider);

    setupTab(new TextView(this), "Search", new Intent(this,Search.class),R.drawable.icon_search);
    setupTab(new TextView(this), "Info",new Intent(this,Info.class),R.drawable.icon_info);
    setupTab(new TextView(this), "About", new Intent(this,About.class),R.drawable.icon_about);

    mTabHost.setCurrentTab(2);
}
private void setupTab(final View view, final String tag, final Intent i_TagIntent, int i_Icon) {
    View tabview = createTabView(mTabHost.getContext(), tag,i_Icon);

    TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(
            new Intent(i_TagIntent));
    mTabHost.addTab(setContent);
}

private static View createTabView(final Context context, final String text, int i_Icon) {
    View view = LayoutInflater.from(context).inflate(R.layout.tabs_bg, null);
    TextView tv = (TextView) view.findViewById(R.id.tabsText);
    tv.setText(text);

    ImageView icon = (ImageView) view.findViewById(R.id.tabsIcon);
    icon.setImageResource(i_Icon);

    return view;
}
private void setupTabHost() {
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();
}
  • 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-30T16:15:24+00:00Added an answer on May 30, 2026 at 4:15 pm

    I am currently working on tab hosts as well, and I have yet to diagnose your specific issue. However, I do have one bit of what I hope is helpful advice. You have set up your code to hide your action/title bar programmatically. There is another way to do this, that I would suggest is cleaner. With the way you are doing it, the first time you launch this app on your emulator, you will see the bar pop up for a moment and then disappear. The second time you open the app, it won’t appear. Beyond that, as you switch activities, sometimes it will reappear before that particular line of code executes. So, the better way to get the result of no action/title bar is via the AndroidManifest.xml document:

    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:theme="@android:style/Theme.Holo.NoActionBar"
            android:name=".Polling"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />
    
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
        <activity 
    

    As you can see, the fifth (5) line of this code is what I just mentioned. I suppose you could call this a design philosophy or best practice, but it looks much better on the screen when you add the line in the XML rather than the code. Doing it this way prevents the times where the action/title bar does appear – it will always be gone.

    My final note would be about your tab question. I encourage you to take a look at this page: http://developer.android.com/guide/topics/ui/actionbar.html and scroll/Ctrl+f to the portion about Adding Navigation Tabs. These are how some newer Google applications are accomplishing the role tabs will play in your application. Unfortunately, it’s fairly more complex than TabHost. I was in the exact same boat as you a couple days ago: making an app where I got rid of my action bar. Then I discovered this action bar tab system (after having seen it on my own android phone and liking it) and decided I wanted to employ it instead of a tab host. But… like I said, it’s a bit over my head still, so I’m going to have to learn a few precursors first.

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

Sidebar

Related Questions

I have recently built my own site www.poolspots.com. I am new to css and
In a recent project, I built my own MVC framework in PHP. One of
Need to use own imaged markers instead built-in pins. I have several questions. 1.
I'm just getting my feet wet with Android and have built a UI that
I built my own Controller class which inherits from BaseController . However the ControllerContext
I have built my own URL scheme for my App. As far as I
I just found out that the jQueryUI now has it's own built-in auto-complete combo
Update: I have provided complete code example in answer below. I have built my
I built my own login system, and I also have a MediaWiki installed for
I have a Rakefile which, on my own-built Ruby 1.9.3 installation, correctly outputs the

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.