-1

I have created 2 tabs, these 2 tabs individually when on clicked open their respective layouts defined in their activity.

All i want now is to show a different layout on my screen when Tab activity is called. E.g. I don't want to show the content of of the tabs but the content of another layout.

How can i do it?

Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39

2 Answers2

2

This is what i was trying to do.

    Intent intent1 = new Intent(this, FacebookLoginPage.class);
    tabHost.addTab(tabHost.newTabSpec("Facebook").setIndicator("",
            res.getDrawable(R.drawable.ic_launcher)).setContent(intent1));

    Intent intent2 = new Intent(this, TwitterLoginPage.class);
    tabHost.addTab(tabHost.newTabSpec("Twitter").setIndicator("",
            res.getDrawable(R.drawable.ic_launcher)).setContent(intent2));

    Intent intent3 = new Intent(this, GmaiLoginPage.class);
    tabHost.addTab(tabHost.newTabSpec("Gmail").setIndicator("")
            .setContent(intent3));

    tabHost.setCurrentTab(2);
    tabHost.getTabWidget().getChildAt(2).setVisibility(View.GONE);
Yauraw Gadav
  • 1,706
  • 1
  • 18
  • 39
0

Is this what you want to do? Open an activity which shown two tabs and additional information. If one of the tabs is selected then open an activity showing the contents for that tab but not the tabs itself.

In this case consider using a "normal" activity A containing a TabHost and whatever layout you want. If the tab is selected start a new activity B showing the content for that tab. With the back-key navigate back to the first activity A and select the other tab, e.g. Alternatively you might embed the TabHost (may be as fragment) in activity B also to directly switch between tabs.

Stefan
  • 4,645
  • 1
  • 19
  • 35
  • I have 2 tabs in my program, but when this screen/Tabactivity loads, I don't want to show the content of any of these tabs unless user clicks on that particular tab, but i wanted to show the content of other layout when this screen/Tabactivity gets loaded e.g. as a default screen, irrespective what are the contents of those tabs, but i figured it out myself. – Yauraw Gadav Jan 15 '12 at 14:31
  • You can do that be applying what I said in the second paragraph of the answer. – Stefan Jan 15 '12 at 17:06