Please note that the contents of this offline web site may be out of date. To access the most recent documentation visit the online version .
Note that links that point to online resources are green in color and will open in a new window.
We would love it if you could give us feedback about this material by filling this form (You have to be online to fill it)
Android APIs
public static abstract class

ActionBar.Tab

extends Object
java.lang.Object
   ↳ android.support.v7.app.ActionBar.Tab

Class Overview

A tab in the action bar that manages the hiding and showing of Fragment s.

Note: This class is included in the support library for compatibility with API level 7 and higher. If you're developing your app for API level 11 and higher only , you should instead use the framework ActionBar.Tab class.

Developer Guides

For information about how to use action bar tabs, read the Action Bar API guide.

Summary

Constants
int INVALID_POSITION An invalid position for a tab.
Public Constructors
ActionBar.Tab ()
Public Methods
abstract CharSequence getContentDescription ()
Gets a brief description of this tab's content for use in accessibility support.
abstract View getCustomView ()
Retrieve a previously set custom view for this tab.
abstract Drawable getIcon ()
Return the icon associated with this tab.
abstract int getPosition ()
Return the current position of this tab in the action bar.
abstract Object getTag ()
abstract CharSequence getText ()
Return the text of this tab.
abstract void select ()
Select this tab.
abstract ActionBar.Tab setContentDescription (int resId)
Set a description of this tab's content for use in accessibility support.
abstract ActionBar.Tab setContentDescription ( CharSequence contentDesc)
Set a description of this tab's content for use in accessibility support.
abstract ActionBar.Tab setCustomView (int layoutResId)
Set a custom view to be used for this tab.
abstract ActionBar.Tab setCustomView ( View view)
Set a custom view to be used for this tab.
abstract ActionBar.Tab setIcon ( Drawable icon)
Set the icon displayed on this tab.
abstract ActionBar.Tab setIcon (int resId)
Set the icon displayed on this tab.
abstract ActionBar.Tab setTabListener ( ActionBar.TabListener listener)
Set the ActionBar.TabListener that will handle switching to and from this tab.
abstract ActionBar.Tab setTag ( Object obj)
Give this Tab an arbitrary object to hold for later use.
abstract ActionBar.Tab setText (int resId)
Set the text displayed on this tab.
abstract ActionBar.Tab setText ( CharSequence text)
Set the text displayed on this tab.
[Expand]
Inherited Methods
From class java.lang.Object

Constants

public static final int INVALID_POSITION

An invalid position for a tab.

Constant Value: -1 (0xffffffff)

Public Constructors

public ActionBar.Tab ()

Public Methods

public abstract CharSequence getContentDescription ()

Gets a brief description of this tab's content for use in accessibility support.

Returns
  • Description of this tab's content

public abstract View getCustomView ()

Retrieve a previously set custom view for this tab.

Returns

public abstract Drawable getIcon ()

Return the icon associated with this tab.

Returns
  • The tab's icon

public abstract int getPosition ()

Return the current position of this tab in the action bar.

Returns

public abstract Object getTag ()

Returns
  • This Tab's tag object.

public abstract CharSequence getText ()

Return the text of this tab.

Returns
  • The tab's text

public abstract void select ()

Select this tab. Only valid if the tab has been added to the action bar.

public abstract ActionBar.Tab setContentDescription (int resId)

Set a description of this tab's content for use in accessibility support. If no content description is provided the title will be used.

Parameters
resId A resource ID referring to the description text
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setContentDescription ( CharSequence contentDesc)

Set a description of this tab's content for use in accessibility support. If no content description is provided the title will be used.

Parameters
contentDesc Description of this tab's content
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setCustomView (int layoutResId)

Set a custom view to be used for this tab. This overrides values set by setText(CharSequence) and setIcon(Drawable) .

Parameters
layoutResId A layout resource to inflate and use as a custom tab view
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setCustomView ( View view)

Set a custom view to be used for this tab. This overrides values set by setText(CharSequence) and setIcon(Drawable) .

Parameters
view Custom view to be used as a tab.
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setIcon ( Drawable icon)

Set the icon displayed on this tab.

Parameters
icon The drawable to use as an icon
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setIcon (int resId)

Set the icon displayed on this tab.

Parameters
resId Resource ID referring to the drawable to use as an icon
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setTabListener ( ActionBar.TabListener listener)

Set the ActionBar.TabListener that will handle switching to and from this tab. All tabs must have a TabListener set before being added to the ActionBar.

Parameters
listener Listener to handle tab selection events
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setTag ( Object obj)

Give this Tab an arbitrary object to hold for later use.

Parameters
obj Object to store
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setText (int resId)

Set the text displayed on this tab. Text may be truncated if there is not room to display the entire string.

Parameters
resId A resource ID referring to the text that should be displayed
Returns
  • The current instance for call chaining

public abstract ActionBar.Tab setText ( CharSequence text)

Set the text displayed on this tab. Text may be truncated if there is not room to display the entire string.

Parameters
text The text to display
Returns
  • The current instance for call chaining