Added in API level 1
Deprecated in API level 30

TabHost


open class TabHost : FrameLayout, ViewTreeObserver.OnTouchModeChangeListener
kotlin.Any
   ↳ android.view.View
   ↳ android.view.ViewGroup
   ↳ android.widget.FrameLayout
   ↳ android.widget.TabHost

Container for a tabbed window view. This object holds two children: a set of tab labels that the user clicks to select a specific tab, and a FrameLayout object that displays the contents of that page. The individual elements are typically controlled using this container object, rather than setting values on the child elements themselves.

Summary

Nested classes
abstract

Interface definition for a callback to be invoked when tab changed

abstract

Makes the content of a tab when it is selected.

open

A tab has a tab indicator, content, and a tag that is used to keep track of it.

Inherited XML attributes
Inherited constants
Public constructors
TabHost(context: Context!)

TabHost(context: Context!, attrs: AttributeSet!)

TabHost(context: Context!, attrs: AttributeSet!, defStyleAttr: Int)

TabHost(context: Context!, attrs: AttributeSet!, defStyleAttr: Int, defStyleRes: Int)

Public methods
open Unit

Add a tab.

open Unit

Removes all tabs from the tab widget associated with this tab host.

open Boolean

open Unit

open CharSequence!

open Int

Returns the current tab.

open String?

Returns the tag for the current tab.

open View?

Returns the view for the current tab.

open View!

open FrameLayout!

Get the FrameLayout which holds tab content

open TabWidget!

open TabHost.TabSpec

Creates a new TabSpec associated with this tab host.

open Unit
onTouchModeChanged(isInTouchMode: Boolean)

open Unit

open Unit

Sets the current tab based on its tag.

open Unit

Register a callback to be invoked when the selected state of any of the items in this list changes

open Unit

Call setup() before adding tabs if loading TabHost using findViewById().

open Unit
setup(activityGroup: LocalActivityManager!)

If you are using TabSpec#setContent(android.content.Intent), this must be called since the activityGroup is needed to launch the local activity.

Inherited functions
Inherited properties

Public constructors

TabHost

Added in API level 1
TabHost(context: Context!)

TabHost

Added in API level 1
TabHost(
    context: Context!,
    attrs: AttributeSet!)

TabHost

Added in API level 21
TabHost(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int)

TabHost

Added in API level 21
TabHost(
    context: Context!,
    attrs: AttributeSet!,
    defStyleAttr: Int,
    defStyleRes: Int)

Public methods

addTab

Added in API level 1
open fun addTab(tabSpec: TabHost.TabSpec!): Unit

Deprecated: Deprecated in Java.

Add a tab.

Parameters
tabSpec TabHost.TabSpec!: Specifies how to create the indicator and content.
Exceptions
java.lang.IllegalArgumentException If the passed tab spec has null indicator strategy and / or null content strategy.

clearAllTabs

Added in API level 1
open fun clearAllTabs(): Unit

Deprecated: Deprecated in Java.

Removes all tabs from the tab widget associated with this tab host.

dispatchKeyEvent

Added in API level 1
open fun dispatchKeyEvent(event: KeyEvent!): Boolean

Deprecated: Deprecated in Java.

Parameters
event KeyEvent!: The key event to be dispatched.
Return
Boolean True if the event was handled, false otherwise.

dispatchWindowFocusChanged

Added in API level 1
open fun dispatchWindowFocusChanged(hasFocus: Boolean): Unit

Deprecated: Deprecated in Java.

Parameters
hasFocus Boolean: True if the window containing this view now has focus, false otherwise.

getAccessibilityClassName

Added in API level 23
Deprecated in API level 30
open fun getAccessibilityClassName(): CharSequence!

Deprecated: Deprecated in Java.

getCurrentTab

Added in API level 1
open fun getCurrentTab(): Int

Deprecated: Deprecated in Java.

Returns the current tab.

Return
Int the current tab, may be null if no tab is set as current

getCurrentTabTag

Added in API level 1
open fun getCurrentTabTag(): String?

Deprecated: Deprecated in Java.

Returns the tag for the current tab.

Return
String? the tag for the current tab, may be null if no tab is set as current

getCurrentTabView

Added in API level 1
open fun getCurrentTabView(): View?

Deprecated: Deprecated in Java.

Returns the view for the current tab.

Return
View? the view for the current tab, may be null if no tab is set as current

getCurrentView

Added in API level 1
open fun getCurrentView(): View!

Deprecated: Deprecated in Java.

getTabContentView

Added in API level 1
open fun getTabContentView(): FrameLayout!

Deprecated: Deprecated in Java.

Get the FrameLayout which holds tab content

getTabWidget

Added in API level 1
open fun getTabWidget(): TabWidget!

Deprecated: Deprecated in Java.

newTabSpec

Added in API level 1
open fun newTabSpec(tag: String): TabHost.TabSpec

Deprecated: Deprecated in Java.

Creates a new TabSpec associated with this tab host.

Parameters
tag String: tag for the tab specification, must be non-null
Return
TabHost.TabSpec This value cannot be null.
Exceptions
java.lang.IllegalArgumentException If the passed tag is null

onTouchModeChanged

Added in API level 1
open fun onTouchModeChanged(isInTouchMode: Boolean): Unit

Deprecated: Deprecated in Java.

Parameters
isInTouchMode Boolean: True if the view hierarchy is now in touch mode, false otherwise.

setCurrentTab

Added in API level 1
open fun setCurrentTab(index: Int): Unit

Deprecated: Deprecated in Java.

setCurrentTabByTag

Added in API level 1
open fun setCurrentTabByTag(tag: String!): Unit

Deprecated: Deprecated in Java.

Sets the current tab based on its tag.

Parameters
tag String!: the tag for the tab to set as current

setOnTabChangedListener

Added in API level 1
open fun setOnTabChangedListener(l: TabHost.OnTabChangeListener!): Unit

Deprecated: Deprecated in Java.

Register a callback to be invoked when the selected state of any of the items in this list changes

Parameters
l TabHost.OnTabChangeListener!: The callback that will run

setup

Added in API level 1
open fun setup(): Unit

Deprecated: Deprecated in Java.

Call setup() before adding tabs if loading TabHost using findViewById(). However: You do not need to call setup() after getTabHost() in TabActivity. Example:

mTabHost = (TabHost)findViewById(R.id.tabhost);
 mTabHost.setup();
 mTabHost.addTab(TAB_TAG_1, "Hello, world!", "Tab 1");

setup

Added in API level 1
open fun setup(activityGroup: LocalActivityManager!): Unit

Deprecated: Deprecated in Java.

If you are using TabSpec#setContent(android.content.Intent), this must be called since the activityGroup is needed to launch the local activity. This is done for you if you extend android.app.TabActivity.

Parameters
activityGroup LocalActivityManager!: Used to launch activities for tab content.