Search code examples
androidandroid-intentandroid-activityandroid-tabhost

Android tabHost: How do I open an activity outside the tabHost for just one tab?


I have a basic tabHost with 3 tabs(Say tab1,tab2 and tab3) and the class firing that up extends ActivityGroup(I know its deprecated ;P ). So all tabs open up inside the tabHost Tab1 and Tab2 open up an activity inside the tabHost using the standard Intents

I want to open an new activity that is not contained in the tabHost when I click on tab3 but tab2 and tab1 should still open up in the tabHost.

So essentially I want only tab3 to behave like it would have had I extended from Activity instead of ActivityGroup.

PS: Im fairly new to android so let me know if I need to add any more information.


Solution

  • i know its old, but i just had the same problem, maybe someone needs it for future references. when someone clicks on the fourth tab, it opens a new activity outside of the tabhost

    TabHost tabHost = (TabHost)findViewById(android.R.id.tabhost);
    tabHost.getTabWidget().getChildTabViewAt(3).setOnClickListener(new OnClickListener() {
    
                @Override
                public void onClick(View arg0) {
    
                     // start new activity here
                }
    
            });