# TabHost.TabSpec

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)

# TabSpec

*** ** * ** ***

Kotlin\|[Java](https://developer.android.com/reference/android/widget/TabHost.TabSpec "View this page in Java")  

```
open class TabSpec
```

|---|------------------------------------------------------------------------------------------------------------------|
| [kotlin.Any](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-any/index.html)                                   ||
| ↳ | [android.widget.TabHost.TabSpec](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#) |

*** ** * ** ***

| **This class was deprecated in API level 30.**
|
| Deprecated in Java.

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](https://developer.android.com/reference/kotlin/android/view/View.html#)2) a[TabContentFactory](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabContentFactory)that creates the[View](https://developer.android.com/reference/kotlin/android/view/View.html#)content. 3) an[Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)that launches an[android.app.Activity](https://developer.android.com/reference/kotlin/android/app/Activity.html#).

## Summary

|                                                                                                                                                                                                                                                                                       Public methods                                                                                                                                                                                                                                                                                       ||
|--------------------------------------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| open[String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html)                   | [getTag](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#getTag())`()` Returns the tag for this tab specification.                                                                                                                                                                                                                                                                                                                                   |
| open[TabHost.TabSpec](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#)! | [setContent](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#setContent(android.content.Intent))`(`intent:` `[Intent](https://developer.android.com/reference/kotlin/android/content/Intent.html#)!`)` Specify an intent to use to launch an activity as the tab content.                                                                                                                                                                            |
| open[TabHost.TabSpec](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#)! | [setContent](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#setContent(android.widget.TabHost.TabContentFactory))`(`contentFactory:` `[TabHost.TabContentFactory](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabContentFactory)!`)` Specify a[android.widget.TabHost.TabContentFactory](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabContentFactory)to use to create the content of the tab. |
| open[TabHost.TabSpec](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#)! | [setContent](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#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.                                                                                                                                                                                             |
| open[TabHost.TabSpec](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#)! | [setIndicator](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#setIndicator(android.view.View))`(`view:` `[View](https://developer.android.com/reference/kotlin/android/view/View.html#)!`)` Specify a view as the tab indicator.                                                                                                                                                                                                                    |
| open[TabHost.TabSpec](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#)! | [setIndicator](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#setIndicator(kotlin.CharSequence))`(`label:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`)` Specify a label as the tab indicator.                                                                                                                                                                                                 |
| open[TabHost.TabSpec](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#)! | [setIndicator](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabSpec#setIndicator(kotlin.CharSequence,%20android.graphics.drawable.Drawable))`(`label:` `[CharSequence](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-char-sequence/index.html)!`, `icon:` `[Drawable](https://developer.android.com/reference/kotlin/android/graphics/drawable/Drawable.html#)!`)` Specify a label and icon as the tab indicator.                                  |

## Public methods

### getTag

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun getTag(): String
```

**Deprecated:** *Deprecated in Java.*

Returns the tag for this tab specification.

|                                                                      Return                                                                      ||
|----------------------------------------------------------------------------------|----------------------------------------------------------------|
| [String](https://kotlinlang.org/api/latest/jvm/stdlib/kotlin/-string/index.html) | the tag for this tab specification This value cannot be`null`. |

### setContent

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setContent(intent: Intent!): TabHost.TabSpec!
```

**Deprecated:** *Deprecated in Java.*

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

### setContent

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setContent(contentFactory: TabHost.TabContentFactory!): TabHost.TabSpec!
```

**Deprecated:** *Deprecated in Java.*

Specify a[android.widget.TabHost.TabContentFactory](https://developer.android.com/reference/kotlin/android/widget/TabHost.TabContentFactory)to use to create the content of the tab.  

### setContent

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setContent(viewId: Int): TabHost.TabSpec!
```

**Deprecated:** *Deprecated in Java.*

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

### setIndicator

Added in[API level 4](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  
Deprecated in[API level 30](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setIndicator(view: View!): TabHost.TabSpec!
```

**Deprecated:** *Deprecated in Java.*

Specify a view as the tab indicator.  

### setIndicator

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setIndicator(label: CharSequence!): TabHost.TabSpec!
```

**Deprecated:** *Deprecated in Java.*

Specify a label as the tab indicator.  

### setIndicator

Added in[API level 1](https://developer.android.com/guide/topics/manifest/uses-sdk-element.html#ApiLevels)  

```
open fun setIndicator(
    label: CharSequence!, 
    icon: Drawable!
): TabHost.TabSpec!
```

**Deprecated:** *Deprecated in Java.*

Specify a label and icon as the tab indicator.