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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:42:43+00:00 2026-06-05T03:42:43+00:00

I am creating a custom tabhost , on each tab spec open different activity

  • 0

I am creating a custom tabhost , on each tab spec open different activity . I want to get tab host on sub activity for finding Linear layout on tab host screen.

select_item.xml (Tab Host Layout)

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >

<include
    android:id="@+id/include1"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    layout="@layout/outcom_actionbar" >
</include>

<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" >

        <View
            android:layout_width="fill_parent"
            android:layout_height="0.5dip"
            android:background="#fff" />

        <TabWidget
            android:id="@android:id/tabs"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="0dip"
            android:layout_marginRight="0dip" />

        <View
            android:layout_width="fill_parent"
            android:layout_height="2dip"
            android:background="#696969" />

        <View
            android:layout_width="fill_parent"
            android:layout_height="2dip"
            android:background="#add23b" />

        <FrameLayout
            android:id="@android:id/tabcontent"
            android:layout_width="fill_parent"
            android:layout_height="fill_parent" />
    </LinearLayout>
</TabHost>

</LinearLayout>

SelectItem.java (Custom Tab Host)

public class SelectItem extends TabActivity {   

private TabHost mTabHost;

private void setupTabHost() {
    mTabHost = (TabHost) findViewById(android.R.id.tabhost);
    mTabHost.setup();
}

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.select_item);   
    context=this;       

    setupTabHost();
    mTabHost.getTabWidget().setDividerDrawable(null);
    setupTab(new TextView(this), getString(R.string.Positions),Constants.ActivityName.Positions.toString());
    setupTab(new TextView(this), getString(R.string.Sever),Constants.ActivityName.Sever.toString());

}

private void setupTab(final View view, final String tag,final String activityName) {
    View tabview = createTabView(mTabHost.getContext(), tag);

    TabSpec setContent = mTabHost.newTabSpec(tag).setIndicator(tabview).setContent(new TabContentFactory() {
        public View createTabContent(String tag) {return view;}
    });
    Intent  intent =null;
    if(activityName.compareToIgnoreCase(Constants.ActivityName.Positions.toString())==0)        
        intent = new Intent().setClass(this, Items.class);  
    else if(activityName.compareToIgnoreCase(Constants.ActivityName.Sever.toString())==0)
        intent = new Intent().setClass(this, Sever.class);      
    intent.putExtra(Constants.PROJECT_ID, projectId);
    setContent.setContent(intent);
    mTabHost.addTab(setContent);

}

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

}

On Server activity i want to get view of LinearLayout of select_item.xml file. But i am able to get details of tab host in Sever activity.

Please suggest me usable link or sample code.

  • 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-05T03:42:45+00:00Added an answer on June 5, 2026 at 3:42 am

    Here is an example that may help you out. Click here
    Look at the link and check out his project on GitHub. It really helped me out.

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

Sidebar

Related Questions

I'm looking for a tutorial that explains creating custom usercontrols in WPF. I want
I need a help about creating custom wpf controls.I want to create a template
I am creating custom Swing components and want to provide a UI that looks
I'm stuck with creating custom adapter. I want to setOnClickListener on the buttons inside
I just started with creating custom objects in javascript. I want to set this.someObjVar
I am creating a custom bar above a TabHost. For some reason the custom
I am creating custom html helper for my datepicker. i want to pass inside
I am creating a Custom dialog where I want to use both DatePicker and
i'm creating custom title for activity by disabling standard one and managing everything myself.
I have a custom Tab Indicator to make my tabs. However, I want to

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.