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 TabContentFactory that creates the View content. 3) an Intent that launches an android.app.Activity.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-02-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-02-10 UTC."],[],[],null,["# TabHost.TabSpec\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)\n\nTabSpec\n=======\n\n*** ** * ** ***\n\nKotlin \\|[Java](/reference/android/widget/TabHost.TabSpec \"View this page in Java\") \n\n```\nopen class TabSpec\n```\n\n|---|-------------------------------------|\n| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html) ||\n| ↳ | [android.widget.TabHost.TabSpec](#) |\n\n*** ** * ** ***\n\n| **This class was deprecated in API level 30.**\n|\n| Deprecated in Java.\n\nA 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](../view/View.html#) 2) a [TabContentFactory](/reference/kotlin/android/widget/TabHost.TabContentFactory) that creates the [View](../view/View.html#) content. 3) an [Intent](../content/Intent.html#) that launches an [android.app.Activity](../app/Activity.html#).\n\nSummary\n-------\n\n| Public methods ||\n|---------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| open [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | [getTag](#getTag())`()` Returns the tag for this tab specification. |\n| open [TabHost.TabSpec](#)! | [setContent](#setContent(android.content.Intent))`(`intent:` `[Intent](../content/Intent.html#)!`)` Specify an intent to use to launch an activity as the tab content. |\n| open [TabHost.TabSpec](#)! | [setContent](#setContent(android.widget.TabHost.TabContentFactory))`(`contentFactory:` `[TabHost.TabContentFactory](/reference/kotlin/android/widget/TabHost.TabContentFactory)!`)` Specify a [android.widget.TabHost.TabContentFactory](/reference/kotlin/android/widget/TabHost.TabContentFactory) to use to create the content of the tab. |\n| open [TabHost.TabSpec](#)! | [setContent](#setContent(kotlin.Int))`(`viewId:` `[Int](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-int/index.html)`)` Specify the id of the view that should be used as the content of the tab. |\n| open [TabHost.TabSpec](#)! | [setIndicator](#setIndicator(android.view.View))`(`view:` `[View](../view/View.html#)!`)` Specify a view as the tab indicator. |\n| open [TabHost.TabSpec](#)! | [setIndicator](#setIndicator(kotlin.CharSequence))`(`label:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` Specify a label as the tab indicator. |\n| open [TabHost.TabSpec](#)! | [setIndicator](#setIndicator(kotlin.CharSequence,%20android.graphics.drawable.Drawable))`(`label:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`, `icon:` `[Drawable](../graphics/drawable/Drawable.html#)!`)` Specify a label and icon as the tab indicator. |\n\nPublic methods\n--------------\n\n### getTag\n\nAdded in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun getTag(): String\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nReturns the tag for this tab specification.\n\n| Return ||\n|----------------------------------------------------------------------------------|-----------------------------------------------------------------|\n| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | the tag for this tab specification This value cannot be `null`. |\n\n### setContent\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setContent(intent: Intent!): TabHost.TabSpec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nSpecify an intent to use to launch an activity as the tab content. \n\n### setContent\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setContent(contentFactory: TabHost.TabContentFactory!): TabHost.TabSpec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nSpecify a [android.widget.TabHost.TabContentFactory](/reference/kotlin/android/widget/TabHost.TabContentFactory) to use to create the content of the tab. \n\n### setContent\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setContent(viewId: Int): TabHost.TabSpec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nSpecify the id of the view that should be used as the content of the tab. \n\n### setIndicator\n\nAdded in [API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \nDeprecated in [API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setIndicator(view: View!): TabHost.TabSpec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nSpecify a view as the tab indicator. \n\n### setIndicator\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setIndicator(label: CharSequence!): TabHost.TabSpec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nSpecify a label as the tab indicator. \n\n### setIndicator\n\nAdded in [API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels) \n\n```\nopen fun setIndicator(\n label: CharSequence!, \n icon: Drawable!\n): TabHost.TabSpec!\n```\n\n**Deprecated:** *Deprecated in Java.*\n\nSpecify a label and icon as the tab indicator."]]