public class

TabWidget

extends LinearLayout
implements View.OnFocusChangeListener
java.lang.Object
   ↳ android.view.View
     ↳ android.view.ViewGroup
       ↳ android.widget.LinearLayout
         ↳ android.widget.TabWidget

Class Overview

Displays a list of tab labels representing each page in the parent's tab collection. The container object for this widget is TabHost. When the user selects a tab, this object sends a message to the parent container, TabHost, to tell it to switch the displayed page. You typically won't use many methods directly on this object. The container TabHost is used to add labels, add the callback handler, and manage callbacks. You might call this object to iterate the list of tabs, or to tweak the layout of the tab list, but most methods should be called on the containing TabHost object.

Summary

[Expand]
Inherited XML Attributes
From class android.widget.LinearLayout
From class android.view.ViewGroup
From class android.view.View
[Expand]
Inherited Constants
From class android.widget.LinearLayout
From class android.view.ViewGroup
From class android.view.View
Public Constructors
TabWidget(Context context)
TabWidget(Context context, AttributeSet attrs)
TabWidget(Context context, AttributeSet attrs, int defStyle)
Public Methods
void addView(View child)
Adds a child view.
void childDrawableStateChanged(View child)
If {link #addStatesFromChildren} is true, refreshes this group's drawable state (to include the states from its children).
void dispatchDraw(Canvas canvas)
Called by draw to draw the child views.
void focusCurrentTab(int index)
Sets the current tab and focuses the UI on it.
void onFocusChange(View v, boolean hasFocus)
Called when the focus state of a view has changed.
void setCurrentTab(int index)
Sets the current tab.
void setEnabled(boolean enabled)
Set the enabled state of this view.
Protected Methods
void onSizeChanged(int w, int h, int oldw, int oldh)
This is called during layout when the size of this view has changed.
[Expand]
Inherited Methods
From class android.widget.LinearLayout
From class android.view.ViewGroup
From class android.view.View
From class java.lang.Object
From interface android.graphics.drawable.Drawable.Callback
From interface android.view.KeyEvent.Callback
From interface android.view.View.OnFocusChangeListener
From interface android.view.ViewManager
From interface android.view.ViewParent

Public Constructors

public TabWidget (Context context)

public TabWidget (Context context, AttributeSet attrs)

public TabWidget (Context context, AttributeSet attrs, int defStyle)

Public Methods

public void addView (View child)

Adds a child view. If no layout parameters are already set on the child, the default parameters for this ViewGroup are set on the child.

Parameters
child the child view to add

public void childDrawableStateChanged (View child)

If {link #addStatesFromChildren} is true, refreshes this group's drawable state (to include the states from its children).

Parameters
child The child whose drawable state has changed.

public void dispatchDraw (Canvas canvas)

Called by draw to draw the child views. This may be overridden by derived classes to gain control just before its children are drawn (but after its own view has been drawn).

Parameters
canvas the canvas on which to draw the view

public void focusCurrentTab (int index)

Sets the current tab and focuses the UI on it. This method makes sure that the focused tab matches the selected tab, normally at setCurrentTab(int). Normally this would not be an issue if we go through the UI, since the UI is responsible for calling TabWidget.onFocusChanged(), but in the case where we are selecting the tab programmatically, we'll need to make sure focus keeps up.

Parameters
index The tab that you want focused (highlighted in orange) and selected (tab brought to the front of the widget)

public void onFocusChange (View v, boolean hasFocus)

Called when the focus state of a view has changed.

Parameters
v The view whose state has changed.
hasFocus The new focus state of v.

public void setCurrentTab (int index)

Sets the current tab. This method is used to bring a tab to the front of the Widget, and is used to post to the rest of the UI that a different tab has been brought to the foreground. Note, this is separate from the traditional "focus" that is employed from the view logic. For instance, if we have a list in a tabbed view, a user may be navigating up and down the list, moving the UI focus (orange highlighting) through the list items. The cursor movement does not effect the "selected" tab though, because what is being scrolled through is all on the same tab. The selected tab only changes when we navigate between tabs (moving from the list view to the next tabbed view, in this example). To move both the focus AND the selected tab at once, please use setCurrentTab(int). Normally, the view logic takes care of adjusting the focus, so unless you're circumventing the UI, you'll probably just focus your interest here.

Parameters
index The tab that you want to indicate as the selected tab (tab brought to the front of the widget)

public void setEnabled (boolean enabled)

Set the enabled state of this view. The interpretation of the enabled state varies by subclass.

Parameters
enabled True if this view is enabled, false otherwise.

Protected Methods

protected void onSizeChanged (int w, int h, int oldw, int oldh)

This is called during layout when the size of this view has changed. If you were just added to the view hierarchy, you're called with the old values of 0.

Parameters
w Current width of this view.
h Current height of this view.
oldw Old width of this view.
oldh Old height of this view.