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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T09:21:50+00:00 2026-06-18T09:21:50+00:00

I am pulling my hair out trying to get a simple tabhost to work

  • 0

I am pulling my hair out trying to get a simple tabhost to work with ABS, it seems Android only complicates things more when attempting to “improve” them. I was considering converting my project to use fragemnts for tabs , but that proved to be wayyyyyyyyy to much work for the complex layouts im using in each of my tabs. Id settle now for just a plain ol working tabhost w. working abs bar.

package com.abs.tabs.fragments;

import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.widget.TabHost;
import android.widget.Toast;

import com.actionbarsherlock.app.ActionBar;
import com.actionbarsherlock.app.SherlockActivity;

import com.actionbarsherlock.view.MenuItem;
import com.buhz.feeds.Buhdz;
import com.buhz.login.R;
import com.buhzhyve.localz.Localz;
import com.buhzhyve.trails.Trails;
import com.buhzhyve.trendz.Trendz;

public class FragmentTabs extends SherlockActivity {
    ActionBar actionBar;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
         setTheme(SampleList.THEME); //Used for theme switching in samples
        super.onCreate(savedInstanceState);
        setContentView(R.layout.tabs);


        actionBar=getSupportActionBar();

         Resources res = getResources(); // Resource object to get Drawables

            TabHost tabHost =(TabHost) findViewById(android.R.id.tabhost);  // The activity TabHost

            TabHost.TabSpec spec;  // Resusable TabSpec for each tab

            Intent intent;  // Reusable Intent for each tab

            // Do the same for the other tabs

            intent = new Intent().setClass(this, Buhdz.class);

            spec = tabHost.newTabSpec("Buhdz").setIndicator("Feeds",

                              res.getDrawable(R.drawable.buhdz_tab_icon))

                          .setContent(intent);

            tabHost.addTab(spec);

         // Do the same for the other tabs

            intent = new Intent().setClass(this, Localz.class);

            spec = tabHost.newTabSpec("Localz").setIndicator("Locals",

                              res.getDrawable(R.drawable.locals_tab_icon))

                          .setContent(intent);

            tabHost.addTab(spec);



            intent = new Intent().setClass(this, Trendz.class);

            spec = tabHost.newTabSpec("Trendz").setIndicator("Trends",

                              res.getDrawable(R.drawable.trends_tab_icon))

                          .setContent(intent);

            tabHost.addTab(spec);



            intent = new Intent().setClass(this, Localz.class);

            spec = tabHost.newTabSpec("convos").setIndicator("Convos",

                              res.getDrawable(R.drawable.convos_tab_icon))

                          .setContent(intent);

            tabHost.addTab(spec);

         // Create an Intent to launch an Activity for the tab (to be reused)

            intent = new Intent().setClass(this, Trails.class);

            // Initialize a TabSpec for each tab and add it to the TabHost

            spec = tabHost.newTabSpec("Trails").setIndicator("Trails",

                              res.getDrawable(R.drawable.trails_tab_icon))

                          .setContent(intent);

            tabHost.addTab(spec);
            tabHost.setCurrentTab(4);
    }

    @Override
    public boolean onCreateOptionsMenu(com.actionbarsherlock.view.Menu menu) {
        com.actionbarsherlock.view.MenuInflater inflater = getSupportMenuInflater();
        inflater.inflate(R.menu.activity_main, menu);
        return super.onCreateOptionsMenu(menu);
    }
    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        switch (item.getItemId()) {
        case R.id.item1:
            return true;
        case R.id.subItem1:
            Toast.makeText(this, "Sub Menu item 1 tapped", Toast.LENGTH_SHORT).show();
            return true;
        case R.id.subItem2:
            Toast.makeText(this, "Sub Menu item 2 tapped", Toast.LENGTH_SHORT).show();
            return true;
        default:
            break;
        }
        return super.onOptionsItemSelected(item);
    }
}
  • 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-18T09:21:51+00:00Added an answer on June 18, 2026 at 9:21 am
    1. Use this library: https://github.com/JakeWharton/Android-ViewPagerIndicator, you can find inside this library some samples with tabs like you want and works with sherlockactionbar.
    2. Visit this question: Actionbarsherlock + tabs + multi fragments?.
    3. Ask me if you got in trouble.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm pulling my hair out here trying to get CSS to position only a
I have been pulling my hair out trying to get the shadows to work
I'm pulling my hair out... Trying to get Drupal Boost to work on a
Pardon the simple question, but I am pulling my hair out trying to get
I've been pulling my hair out trying to use jQuery.get() to pull in my
I have been pulling my hair out trying to make this work. I have
After pulling my hair out trying to get my local IIS server to not
I've been pulling my hair out trying to get some data to come across
I've been pulling my hair out trying to get my own offline Mobile Atlas
Pulling my hair out over this one, I am trying to get the diff

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.