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

The Archive Base Latest Questions

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

Here i make 5 Tab buttons that are working proper but now i want

  • 0

Here i make 5 Tab buttons that are working proper but now i want to add icon with each Tab, How to add tab icon respect to Tab buttons…. Please guide/help me..

i am using stackOverflow first time please tell if here i missed any steps while posting this code…
Thanks in advance

package com.vishesh.soapbox;
import android.app.TabActivity;
import android.content.Context;
import android.content.Intent;
import android.content.res.Resources;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.TabHost;
import android.widget.TextView;
import android.widget.TabHost.TabSpec;

public class Start extends TabActivity {
private TabHost tabHost;
//Resources res=getResources();

/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.start);
    //textView for signout from application 
    TextView signout=(TextView)findViewById(R.id.signout);
    signout.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
        finish();   
        }
    });

    // scan button use for read the BarCode through RedLaser
    Button scan=(Button)findViewById(R.id.scan);
    final Intent intent=new Intent(this,RLSample.class);
    scan.setOnClickListener(new View.OnClickListener() {
        public void onClick(View v) {
            startActivity(intent);
        }
    });

    //for Tab button

    tabHost=getTabHost();
    setupTabhost();

    Intent intent1=new Intent().setClass(this, SoapBox.class);
    setupTab(new TextView(this),"SoapBox", intent1);
    Intent intent2=new Intent().setClass(this, Profile.class);
    setupTab(new TextView(this),"Profile", intent2);
    Intent intent3=new Intent().setClass(this, Challenges.class);
    setupTab(new TextView(this),"Challenges", intent3);
    Intent intent4=new Intent().setClass(this, Vault.class);
    setupTab(new TextView(this),"Vault", intent4);
    Intent intent5=new Intent().setClass(this, More.class);
    setupTab(new TextView(this),"More", intent5);
    tabHost.setCurrentTab(0);
    }
    private void setupTabhost()
    {
        tabHost=(TabHost)findViewById(android.R.id.tabhost);
        tabHost.setup();
    }
    private void setupTab(final View view, final String tag, Intent intent)
    {
        View tabView=createTabView(tabHost.getContext(),tag);
        TabSpec tabSpec=tabHost.newTabSpec(tag).setIndicator(tabView).setContent(intent);
        tabHost.addTab(tabSpec);
    }
    private static View createTabView(final Context context, final String text)
    {
        View view=LayoutInflater.from(context).inflate(R.layout.start_tabs_bg, null);
        TextView textView=(TextView)view.findViewById(R.id.tabsText);
        textView.setText(text);
        return view;
    }
}
  • 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:10:45+00:00Added an answer on May 23, 2026 at 1:10 am

    Vishesh,

    If you look at the example HERE…

    spec = tabHost.newTabSpec("albums").setIndicator("Albums",
                          res.getDrawable(R.drawable.ic_tab_albums))
                      .setContent(intent);
    

    The drawable icon is passed in the call to setIndicator(). And you could replace both “Albums” strings with your tag variable.

    Although, it currently looks like you are using a custom View for your tabs. You would just have to add an ImageView to the layout and set the drawable to the icon you desire.

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

Sidebar

Related Questions

![enter image description here][1] I want to make a tab layout application, in which
My goal here is to make a button. I want the text to sit
Here is my code : What i want is just to make scrollbar available
I want make the control height as double when the mouse is over that
I am trying to make one of my tab buttons go to the root
I want to add a tab with content from a page I made to
I am trying to make form submit with TAB button. It is working on
I want to create the TabBar as like Below image: Here, all tab bar
I'm utilizing the code posted by Jesper Palm here: Make user control display outside
Does the @error line even make sense here? Would it even be hit in

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.