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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T21:47:56+00:00 2026-05-27T21:47:56+00:00

I want to create an Application with tabs, and I have found this guide

  • 0

I want to create an Application with tabs, and I have found this guide http://developer.android.com/resources/tutorials/views/hello-tabwidget.html on the Internet, I have choosen to follow.

I have created an XML-file for the Layout, that looks like this:

<?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="50dip">
  <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" 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">
      <TableLayout android:id="@+id/aTableLayout" android:layout_width="fill_parent" android:layout_height="fill_parent">
      </TableLayout>
    </FrameLayout>
  </LinearLayout>
</TabHost>

I also created a class to create the Tabs due to the guide, which is shown below.

public class GuiTabs extends TabActivity {
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.tabslayout);

    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, GuiRegistration.class);

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

    tabHost.setCurrentTabByTag("Reg");
  }
}

Now I need to generate the content of the tabs, where one of the tabs is GuiRegistration.
I have designed the GuiRegistration in a XML-file, but I also need to add actions to buttons e.g., so I have to use the GuiRegistration-class.
But how can I create the tab, because I have tried using

setContentView(R.layout.registration)

Design the tab directy in the class

And

public class GuiRegistration extends Activity {
  public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    View aTabLayout = findViewById(R.id.aTableLayout);
    ViewGroup vGroup = (ViewGroup) aTabLayout.getParent();
    int index = vGroup.indexOfChild(aTabLayout);
    vGroup.removeViewAt(index);
    View newTabLayout = getLayoutInflater().inflate(R.layout.registration, vGroup, false);
    vGroup.addView(newTabLayout, index);
  }
}

But nothing seems to work, can somebody tell me how to make it work?

  • 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-27T21:47:57+00:00Added an answer on May 27, 2026 at 9:47 pm

    from the code, your Guiregistration class is not calling
    setContentView(R.layout.registration)

    May be thats why the view is not drawn in the tab.

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

Sidebar

Related Questions

The Android developer guide (http://developer.android.com/resources/tutorials/views/hello-tabwidget.html) states: `You can implement your tab content in one
I want to create an application like this: http://collabedit.com/ What is the most efficient
I want to create an application send an request like http://www.mysiteabc.com/api.php?email=emailtologin@gmail.com&password=123321 and read data
I want to create an application which will have a client and server components.
I want to create an application for Android that will be able to scan
I have seen the Contacts in iPhone Simulator. I want to create an application
I stack with this, I'm trying to create application using TabLayout. I have 3
I want to create application with two Tabs, like follow: MainClass: private TabHost tabHost;
Newbee to Android development. I am developing a application, which have three different tabs.
i want to create reminder application...I am using Notification Manager... I am using this

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.