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

  • Home
  • SEARCH
  • 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 6802819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T19:16:09+00:00 2026-05-26T19:16:09+00:00

I am trying to implement Tab View for my activity. I am getting an

  • 0

I am trying to implement Tab View for my activity. I am getting an error that states.

java.lang.IllegalArgumentException: you must specify a way to create the tab indicator

     Resources res = getResources(); // Resource object to get Drawables
        TabHost tabHost = getTabHost();  // The activity TabHost
        TabHost.TabSpec spec;  // Resusable TabSpec for each tab
        Intent intent;  // Reusable Intent for each tab

        // Create an Intent to launch an Activity for the tab (to be reused)
        intent = new Intent().setClass(this, MonthActivity.class);

        // Initialize a TabSpec for each tab and add it to the TabHost
        spec = tabHost.newTabSpec("Month")
                      .setContent(intent);
        tabHost.addTab(spec);

        // Do the same for the other tabs
        intent = new Intent().setClass(this, WeekActivity.class);
        spec = tabHost.newTabSpec("Week")
                .setContent(intent);
        tabHost.addTab(spec);

        intent = new Intent().setClass(this, DayActivity.class);
        spec = tabHost.newTabSpec("Day")
                .setContent(intent);
        tabHost.addTab(spec);
        tabHost.setCurrentTab(2);

This is my xml and I’ve declared the Activities in the manifest.

<?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="fill_parent"
android:layout_height="fill_parent" >

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:orientation="vertical"
    android:padding="5dp" >

    <TabWidget
        android:id="@android:id/tabs"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" />

    <FrameLayout
        android:id="@android:id/tabcontent"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:padding="5dp" >
        </FrameLayout>
</LinearLayout>

Where am I making my mistake? Thanks for your time and input.

  • 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-26T19:16:09+00:00Added an answer on May 26, 2026 at 7:16 pm

    try this:

    Resources res = getResources(); // Resource object to get Drawables   
    tabHost = getTabHost();  // The activity TabHost  
    TabHost.TabSpec spec;  // Resusable TabSpec for each tab    
    Intent intent;  // Reusable Intent for each tab   
    
    intent = new Intent().setClass(this, First.class);      
    spec = tabHost.newTabSpec("First Tab").setIndicator("First Tab",res.getDrawable(R.drawable.icon)).setContent(intent); 
    tabHost.addTab(spec);   
    
    intent = new Intent().setClass(this, Second.class); 
    spec = tabHost.newTabSpec("Second Tab").setIndicator("Second Tab",res.getDrawable(R.drawable.icon)).setContent(intent); 
    tabHost.addTab(spec); 
    
    tabHost.setCurrentTab(1);
    

    and make sure,your activity must be a TabActivity where you define your TabHost.

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

Sidebar

Related Questions

I am trying to implement a layout that looks like a tabbed view, but
I am trying to implement TabLayout in an Activity, and I keep on getting
I'm trying to implement a tab menu just like the one in Stack Overflow.
Greetings, I'm trying to implement my custom TAB control. I'd like it to be
Am trying to implement a generic way for reading sections from a config file.
when trying to implement an Aspect, that is responsible for catching and logging a
Background: I'm trying to implement a tab control. The tabs are as follows: |
I am trying to implement some tree like that in ASP.NET: alt text http://i.msdn.microsoft.com/w6ws38fw.vbVenusSiteNavigation_TreeView1(en-us,VS.100).gif
I'm trying to implement tab buttons bar and a navigation bar in my android
I'm trying to implement jQuery tabs to replace AJAX tab container. I've followed 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.