Android
android.widget
public class

android.widget.TabHost

java.lang.Object
android.view.View Drawable.Callback KeyEvent.Callback
android.view.ViewGroup ViewManager ViewParent
android.widget.FrameLayout
android.widget.TabHost ViewTreeObserver.OnTouchModeChangeListener

Container for a tabbed window view. This object holds two children: a set of tab labels that the user clicks to select a specific tab, and a FrameLayout object that displays the contents of that page. The individual elements are typically controlled using this container object, rather than setting values on the child elements themselves.

Nested Classes
TabHost.OnTabChangeListener Interface definition for a callback to be invoked when tab changed  
TabHost.TabContentFactory Makes the content of a tab when it is selected. 
TabHost.TabSpec A tab has a tab indictor, content, and a tag that is used to keep track of it. 

Summary

XML Attributes inherited from class android.widget.FrameLayout
XML Attributes inherited from class android.view.ViewGroup
XML Attributes inherited from class android.view.View
Constants inherited from class android.view.ViewGroup
Constants inherited from class android.view.View

Fields

protected      int  mCurrentTab   
protected      LocalActivityManager  mLocalActivityManager   
Fields inherited from class android.view.ViewGroup
Fields inherited from class android.view.View

Public Constructors

            TabHost(Context context)
            TabHost(Context context, AttributeSet attrs)

Public Methods

          void  addTab(TabHost.TabSpec tabSpec)
Add a tab.
          void  clearAllTabs()
Removes all tabs from the tab widget associated with this tab host.
          boolean  dispatchKeyEvent(KeyEvent event)
Dispatch a key event to the next view on the focus path.
          int  getCurrentTab()
          String  getCurrentTabTag()
          View  getCurrentTabView()
          View  getCurrentView()
          FrameLayout  getTabContentView()
Get the FrameLayout which holds tab content
          TabWidget  getTabWidget()
          TabHost.TabSpec  newTabSpec(String tag)
Get a new TabHost.TabSpec associated with this tab host.
          void  onTouchModeChanged(boolean isInTouchMode)
Callback method to be invoked when the touch mode changes.
          void  setCurrentTab(int index)
          void  setCurrentTabByTag(String tag)
          void  setOnTabChangedListener(TabHost.OnTabChangeListener l)
Register a callback to be invoked when the selected state of any of the items in this list changes
          void  setup()

Call setup() before adding tabs if loading TabHost using findViewById().

          void  setup(LocalActivityManager activityGroup)
If you are using setContent(android.content.Intent), this must be called since the activityGroup is needed to launch the local activity.

Protected Methods

          void  onAttachedToWindow()
This is called when the view is attached to a window.
          void  onDetachedFromWindow()
This is called when the view is detached from a window.
Methods inherited from class android.widget.FrameLayout
Methods inherited from class android.view.ViewGroup
Methods inherited from class android.view.View
Methods inherited from class java.lang.Object
Methods inherited from interface android.graphics.drawable.Drawable.Callback
Methods inherited from interface android.view.KeyEvent.Callback
Methods inherited from interface android.view.ViewManager
Methods inherited from interface android.view.ViewParent
Methods inherited from interface android.view.ViewTreeObserver.OnTouchModeChangeListener

Details

Fields

protected int mCurrentTab

protected LocalActivityManager mLocalActivityManager

Public Constructors

public TabHost(Context context)

public TabHost(Context context, AttributeSet attrs)

Public Methods

public void addTab(TabHost.TabSpec tabSpec)

Add a tab.

Parameters

tabSpec Specifies how to create the indicator and content.

public void clearAllTabs()

Removes all tabs from the tab widget associated with this tab host.

public boolean dispatchKeyEvent(KeyEvent event)

Dispatch a key event to the next view on the focus path. This path runs from the top of the view tree down to the currently focused view. If this view has focus, it will dispatch to itself. Otherwise it will dispatch the next node down the focus path. This method also fires any key listeners.

Parameters

event The key event to be dispatched.

public int getCurrentTab()

public String getCurrentTabTag()

public View getCurrentTabView()

public View getCurrentView()

public FrameLayout getTabContentView()

Get the FrameLayout which holds tab content

public TabWidget getTabWidget()

public TabHost.TabSpec newTabSpec(String tag)

Get a new TabHost.TabSpec associated with this tab host.

Parameters

tag required tag of tab.

public void onTouchModeChanged(boolean isInTouchMode)

Callback method to be invoked when the touch mode changes.

public void setCurrentTab(int index)

public void setCurrentTabByTag(String tag)

public void setOnTabChangedListener(TabHost.OnTabChangeListener l)

Register a callback to be invoked when the selected state of any of the items in this list changes

Parameters

l The callback that will run

public void setup()

Call setup() before adding tabs if loading TabHost using findViewById(). However: You do not need to call setup() after getTabHost() in TabActivity. Example:

mTabHost = (TabHost)findViewById(R.id.tabhost);
mTabHost.setup();
mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");















public void setup(LocalActivityManager activityGroup)

If you are using setContent(android.content.Intent), this must be called since the activityGroup is needed to launch the local activity. This is done for you if you extend TabActivity.

Parameters

activityGroup Used to launch activities for tab content.

Protected Methods

protected void onAttachedToWindow()

This is called when the view is attached to a window. At this point it has a Surface and will start drawing. Note that this function is guaranteed to be called before onDraw(Canvas), however it may be called any time before the first onDraw -- including before or after onMeasure(int, int).

protected void onDetachedFromWindow()

This is called when the view is detached from a window. At this point it no longer has a surface for drawing.
Copyright 2007 Google Inc. Build 0.9_r1-98467 - 14 Aug 2008 18:56