Skip to content

Most visited

Recently visited

navigation

TabHost.TabSpec

public class TabHost.TabSpec
extends Object

java.lang.Object
   ↳ android.widget.TabHost.TabSpec


A tab has a tab indicator, content, and a tag that is used to keep track of it. This builder helps choose among these options. For the tab indicator, your choices are: 1) set a label 2) set a label and an icon For the tab content, your choices are: 1) the id of a View 2) a TabHost.TabContentFactory that creates the View content. 3) an Intent that launches an Activity.

Summary

Public methods

String getTag()

Returns the tag for this tab specification.

TabHost.TabSpec setContent(Intent intent)

Specify an intent to use to launch an activity as the tab content.

TabHost.TabSpec setContent(TabHost.TabContentFactory contentFactory)

Specify a TabHost.TabContentFactory to use to create the content of the tab.

TabHost.TabSpec setContent(int viewId)

Specify the id of the view that should be used as the content of the tab.

TabHost.TabSpec setIndicator(View view)

Specify a view as the tab indicator.

TabHost.TabSpec setIndicator(CharSequence label)

Specify a label as the tab indicator.

TabHost.TabSpec setIndicator(CharSequence label, Drawable icon)

Specify a label and icon as the tab indicator.

Inherited methods

From class java.lang.Object

Public methods

getTag

added in API level 4
String getTag ()

Returns the tag for this tab specification.

Returns
String the tag for this tab specification

This value will never be null.

setContent

added in API level 1
TabHost.TabSpec setContent (Intent intent)

Specify an intent to use to launch an activity as the tab content.

Parameters
intent Intent

Returns
TabHost.TabSpec

setContent

added in API level 1
TabHost.TabSpec setContent (TabHost.TabContentFactory contentFactory)

Specify a TabHost.TabContentFactory to use to create the content of the tab.

Parameters
contentFactory TabHost.TabContentFactory

Returns
TabHost.TabSpec

setContent

added in API level 1
TabHost.TabSpec setContent (int viewId)

Specify the id of the view that should be used as the content of the tab.

Parameters
viewId int

Returns
TabHost.TabSpec

setIndicator

added in API level 4
TabHost.TabSpec setIndicator (View view)

Specify a view as the tab indicator.

Parameters
view View

Returns
TabHost.TabSpec

setIndicator

added in API level 1
TabHost.TabSpec setIndicator (CharSequence label)

Specify a label as the tab indicator.

Parameters
label CharSequence

Returns
TabHost.TabSpec

setIndicator

added in API level 1
TabHost.TabSpec setIndicator (CharSequence label, 
                Drawable icon)

Specify a label and icon as the tab indicator.

Parameters
label CharSequence

icon Drawable

Returns
TabHost.TabSpec

This site uses cookies to store your preferences for site-specific language and display options.

Get the latest Android developer news and tips that will help you find success on Google Play.

* Required Fields

Hooray!

Follow Google Developers on WeChat

Browse this site in ?

You requested a page in , but your language preference for this site is .

Would you like to change your language preference and browse this site in ? If you want to change your language preference later, use the language menu at the bottom of each page.

This class requires API level or higher

This doc is hidden because your selected API level for the documentation is . You can change the documentation API level with the selector above the left navigation.

For more information about specifying the API level your app requires, read Supporting Different Platform Versions.

Take a short survey?
Help us improve the Android developer experience. (Dec 2017 Android Platform & Tools Survey)