1

I know how to write tab host,but here the scenario is little bit different
I have a screen ,in that 2 tabs are there 1.ABC 2.XYZ when ever we click on the XYZ tab next page onwords we need to display 4 other tabs P,Q,R,S how to set tabhosts to meet the above criteria please specify any suggestions

2 Answers2

1

You just need to create two classes that extends TabActivity

First that contains

1.ABC
2.XYZ

Second contains

1.P
2.Q
3.R
4.S

Now you have to call startActivity with the Intent of second TabActivity inside onTabChanged() so when Tab XYZ is selected open the second TabActivity.

Lalit Poptani
  • 67,150
  • 23
  • 161
  • 242
0

Add that method into your TabActivity:

    private void addTab(String name, Class<?> c)
    {
        TabHost tabHost = getTabHost();
        Intent intent = new Intent(this, c);
        TabHost.TabSpec spec = tabHost.newTabSpec(name);

        spec.setIndicator(name);
        spec.setContent(intent);
        tabHost.addTab(spec);
    }

    public void addMyFourNewTabs()
    {
        addTab("P", PActivity.class);
        addTab("Q", QActivity.class);
        addTab("R", RActivity.class);
        addTab("S", SActivity.class);
    }

In your Activity where you want to create the new Tabs:

((TabActivity) getParent()).getTabHost().addMyFourNewTabs();
Manitoba
  • 8,522
  • 11
  • 60
  • 122