FileDocCategorySizeDatePackage
TabActivity.javaAPI DocAndroid 1.5 API4401Wed May 06 22:41:54 BST 2009android.app

TabActivity

public class TabActivity extends ActivityGroup
An activity that contains and runs multiple embedded activities or views.

Fields Summary
private android.widget.TabHost
mTabHost
private String
mDefaultTab
private int
mDefaultTabIndex
Constructors Summary
public TabActivity()


      
    
Methods Summary
private voidensureTabHost()

        if (mTabHost == null) {
            this.setContentView(com.android.internal.R.layout.tab_content);
        }
    
public android.widget.TabHostgetTabHost()
Returns the {@link TabHost} the activity is using to host its tabs.

return
the {@link TabHost} the activity is using to host its tabs.

        ensureTabHost();
        return mTabHost;
    
public android.widget.TabWidgetgetTabWidget()
Returns the {@link TabWidget} the activity is using to draw the actual tabs.

return
the {@link TabWidget} the activity is using to draw the actual tabs.

        return mTabHost.getTabWidget();
    
protected voidonChildTitleChanged(Activity childActivity, java.lang.CharSequence title)

        // Dorky implementation until we can have multiple activities running.
        if (getLocalActivityManager().getCurrentActivity() == childActivity) {
            View tabView = mTabHost.getCurrentTabView();
            if (tabView != null && tabView instanceof TextView) {
                ((TextView) tabView).setText(title);
            }
        }
    
public voidonContentChanged()
Updates the screen state (current list and other views) when the content changes.

see
Activity#onContentChanged()

        super.onContentChanged();
        mTabHost = (TabHost) findViewById(com.android.internal.R.id.tabhost);

        if (mTabHost == null) {
            throw new RuntimeException(
                    "Your content must have a TabHost whose id attribute is " +
                    "'android.R.id.tabhost'");
        }
        mTabHost.setup(getLocalActivityManager());
    
protected voidonPostCreate(android.os.Bundle icicle)

        
        super.onPostCreate(icicle);

        ensureTabHost();

        if (mTabHost.getCurrentTab() == -1) {
            mTabHost.setCurrentTab(0);
        }
    
protected voidonRestoreInstanceState(android.os.Bundle state)

        super.onRestoreInstanceState(state);
        ensureTabHost();
        String cur = state.getString("currentTab");
        if (cur != null) {
            mTabHost.setCurrentTabByTag(cur);
        }
        if (mTabHost.getCurrentTab() < 0) {
            if (mDefaultTab != null) {
                mTabHost.setCurrentTabByTag(mDefaultTab);
            } else if (mDefaultTabIndex >= 0) {
                mTabHost.setCurrentTab(mDefaultTabIndex);
            }
        }
    
protected voidonSaveInstanceState(android.os.Bundle outState)

        super.onSaveInstanceState(outState);
        String currentTabTag = mTabHost.getCurrentTabTag();
        if (currentTabTag != null) {
            outState.putString("currentTab", currentTabTag);
        }
    
public voidsetDefaultTab(java.lang.String tag)
Sets the default tab that is the first tab highlighted.

param
tag the name of the default tab

        mDefaultTab = tag;
        mDefaultTabIndex = -1;
    
public voidsetDefaultTab(int index)
Sets the default tab that is the first tab highlighted.

param
index the index of the default tab

        mDefaultTab = null;
        mDefaultTabIndex = index;