title: Android Tabs with TableLayout
body: <p>I want to create an Application with tabs, and I have found this guide <a href="http://developer.android.com/resources/tutorials/views/hello-tabwidget.html" rel="nofollow">http://developer.android.com/resources/tutorials/views/hello-tabwidget.html</a> on the Internet, I have choosen to follow.</p>
  
  <p>I have created an XML-file for the Layout, that looks like this:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;TabHost xmlns:android="http://schemas.android.com/apk/res/android" android:id="@android:id/tabhost" android:layout_width="fill_parent" android:layout_height="50dip"&gt;
    &lt;LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"&gt;
      &lt;TabWidget android:id="@android:id/tabs" android:layout_width="fill_parent" android:layout_height="wrap_content" /&gt;
      &lt;FrameLayout android:id="@android:id/tabcontent" android:layout_width="fill_parent" android:layout_height="fill_parent" android:padding="5dp"&gt;
        &lt;TableLayout android:id="@+id/aTableLayout" android:layout_width="fill_parent" android:layout_height="fill_parent"&gt;
        &lt;/TableLayout&gt;
      &lt;/FrameLayout&gt;
    &lt;/LinearLayout&gt;
  &lt;/TabHost&gt;
  </code></pre>
  
  <p>I also created a class to create the Tabs due to the guide, which is shown below.</p>
  
  <pre><code>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");
    }
  }
  </code></pre>
  
  <p>Now I need to generate the content of the tabs, where one of the tabs is GuiRegistration.<br />
  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. <br />
  But how can I create the tab, because I have tried using </p>
  
  <pre><code>setContentView(R.layout.registration)
  </code></pre>
  
  <p>Design the tab directy in the class</p>
  
  <p>And</p>
  
  <pre><code>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);
    }
  }
  </code></pre>
  
  <p>But nothing seems to work, can somebody tell me how to make it work?</p>