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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T09:19:58+00:00 2026-06-09T09:19:58+00:00

I have 2 tabs: Report and Profile. I want to add a different form

  • 0

I have 2 tabs: Report and Profile.

I want to add a different form (Textview, spinner, etc) in each of the tabs. For now im trying with a button and it should be different button in different tab.

But what i get is i have the same button in both tab. It should show button name ButtonReport in Report Tab and ButtonProfile in Profile Tab.

Below is the picture of it.

enter image description here

I am putting the button code in main.xml.

<?xml version="1.0" encoding="utf-8"?>
<TabHost xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@android:id/tabhost"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent">

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

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

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



        <!-- Start Interface -->
        <TableLayout android:layout_height="wrap_content" android:layout_width="wrap_content" android:id="@+id/tableLayout1" android:alwaysDrawnWithCache="false">  
        <TableRow android:layout_height="fill_parent" android:id="@+id/tableRow3">
            <TableLayout android:id="@+id/tableLayout2" android:layout_width="wrap_content" android:layout_height="wrap_content">

                <Button android:text="Button Report" android:id="@+id/button1" android:layout_width="fill_parent" android:layout_height="wrap_content"></Button>

            </TableLayout>
            </TableRow>     
        </TableLayout>
        <!-- End Interface -->


        </FrameLayout>



    </LinearLayout>

</TabHost>

This is my ReportActivity class and ProfileActivity(same code only different name)

package com.tab;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class ReportActivity extends Activity{
    public void onCreate(Bundle savedInstanceState){
        super.onCreate(savedInstanceState);
        TextView text = new TextView(this);
        text.setText("Artist");
        setContentView(text);
    }
}

This is my MainActivity class

package com.tab;

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

public class MainActivity extends TabActivity {
    private TabHost aTab;
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);

        Resources res = getResources();
        aTab = getTabHost();
        TabHost.TabSpec spec;
        Intent intent;

        //Report Tab
        intent = new Intent(this, ReportActivity.class);

        spec = aTab.newTabSpec("Report")
            .setIndicator("Report", res.getDrawable(R.drawable.tab_icon))
            .setContent(intent);
        aTab.addTab(spec);

        //Profile Tab
        intent = new Intent(this, ProfileActivity.class);

        spec = aTab.newTabSpec("Profile")
            .setIndicator("Profile", res.getDrawable(R.drawable.tab_icon))
            .setContent(intent);
        aTab.addTab(spec);

        aTab.setCurrentTab(1);
    }
}

is there a way to have different form in different tab?

  • 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-09T09:20:01+00:00Added an answer on June 9, 2026 at 9:20 am

    The best way (my opinion) is to use Fragments :
    http://developer.android.com/guide/components/fragments.html

    Fragment are for API Level 11 minimum, but you can work with a compatibility package :
    http://android-developers.blogspot.ch/2011/03/fragments-for-all.html

    So every tab will become a fragment.

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

Sidebar

Related Questions

I have tabs on my page each containing unique content. I want to automatically
So I want to have tabs with default style but I want to handle
I have a tabs as views in my activity. Each tab represents a ListView
I have three tabs. When I press the tab button on the bottom, is
I have some tabs using jQuery UI which work just fine, but I want
I have 4 tabs in my iphone application. When user will click a button
I have a page where I have 4 tabs displaying 4 different reports based
I am trying to disable history and properties tabs from my report manager for
I have tabs on the website: Cinema, Concerts, Clubs, Theatres, Children, Other. Each tab
I have this scenario: on second tab there is a form with submit button

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.