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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:21:48+00:00 2026-06-05T21:21:48+00:00

I have these codes for my two tabs. I would like to change the

  • 0

I have these codes for my two tabs. I would like to change the color but I dont know how to do it. Should it be done in my java file, or in my xml ? Thank You

Here are my codes

import android.app.Activity;
import android.app.TabActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Window;
import android.widget.TabHost;

// This is now the first activity that you see when you enter the app, it derives from      TabActivity
public class TabsActivity extends TabActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    super.onCreate(savedInstanceState);



    // The activity displays a TabHost layout with a TabWidget below the actual  tab contents
    setContentView(R.layout.tabs);

    // Two tabs are added one displays the main list activity, the other an     info activity
    addNewTab("Kalender", MainActivity.class);
    addNewTab("Info", InfoActivity.class);
}


// This function defines and adds a tab to the interface
private void addNewTab(String name, Class<? extends Activity> activityClass)
{
    TabHost tabHost = getTabHost();

    // The new tab will display a separate activity, so it needs an intent for it
    Intent activityIntent = new Intent().setClass(this, activityClass);

    // The TabSpec sets the internal name and the visible name of the newly created    tab
    TabHost.TabSpec spec =     tabHost.newTabSpec(name).setIndicator(name).setContent(activityIntent);

    // Finally, the new tab is added to the TabHost
    tabHost.addTab(spec);
}
}
  • 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-05T21:21:49+00:00Added an answer on June 5, 2026 at 9:21 pm

    Changing text Color and Background color of TAB

        for(int i=0;i<tabHost.getTabWidget().getChildCount();i++)
        {
    
            tabHost.getTabWidget().getChildAt(i).setBackgroundColor(Color.WHITE); //Changing background color of tab
    
            TextView tv = (TextView) tabHost.getTabWidget().getChildAt(i).findViewById(android.R.id.title); /*for Selected Tab changing text color*/
            tv.setTextColor(Color.BLACK);
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have following code in my php page. These are two tabs Inbox and
I have an application which has two Tabs. Both of these are ListFragments. The
I have an existing toolbar and would like to add tabs to it that
I would like to have the tabs on my TabControl displayed on the left,
I would like to know if the two variants of the code examples below
I have these two set of codes, one is to prompt whenever the button
I have use these code to upload two images in folder of the root
We have two code bases for testing and production. The only differences between these
I have a code base, in which for Matrix class, these two definitions are
i have a json file with many elements like these: { code : hfuiew89,

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.