Search code examples
androidandroid-tabhost

How should I embedded a tabHost into every Activity in my App


I wrote a Tabhost below:

public class AppTabhost extends TabActivity {
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        /**find tab host**/
        TabHost tabHost = getTabHost();

    /**add tabs**/
    //tab 1
    tabHost.addTab(tabHost
            .newTabSpec("tab1")
            .setIndicator("tab1")
            .setContent(new Intent(AppTabhost.this, anotherActivity.class)));

    //tab 2
    tabHost.addTab(tabHost
            .newTabSpec("tab2")
            .setIndicator("tab2")
            .setContent(new Intent(AppTabhost.this, theotherActivity.class)));
}

I want to put it on the bottom of every Activity in my App

How can I do?


Solution

  • You could slap an Intent in there like

    Intent I= new Intent(this, Apptabhost.class);
    startIntent(I);
    

    But if you want the tabhost to be physically at the bottom of the screen, I would suggest you define a class that will extend tabhost and not tabhost activity. Since a view hierarchy contains views and not activities.