Most visited

Recently visited

TabLayout.Tab

public static final class TabLayout.Tab
extends Object

java.lang.Object
    android.support.design.widget.TabLayout.Tab


此布局中的选项卡。 实例可以通过newTab()创建。

摘要(Summary)

常量(Constants)

int INVALID_POSITION

选项卡无效的位置。

公共方法(Public methods)

CharSequence getContentDescription()

获取此选项卡的内容的简要说明以用于辅助功能支持。

View getCustomView()

返回用于此选项卡的自定义视图。

Drawable getIcon()

返回与此选项卡关联的图标。

int getPosition()

在操作栏中返回此选项卡的当前位置。

Object getTag()
CharSequence getText()

返回此选项卡的文本。

boolean isSelected()

如果当前选中此选项卡,则返回true。

void select()

选择此选项卡。

TabLayout.Tab setContentDescription(int resId)

设置此选项卡内容的说明以用于辅助功能支持。

TabLayout.Tab setContentDescription(CharSequence contentDesc)

设置此选项卡内容的说明以用于辅助功能支持。

TabLayout.Tab setCustomView(int resId)

设置用于此选项卡的自定义视图。

TabLayout.Tab setCustomView(View view)

设置用于此选项卡的自定义视图。

TabLayout.Tab setIcon(Drawable icon)

设置此选项卡上显示的图标。

TabLayout.Tab setIcon(int resId)

设置此选项卡上显示的图标。

TabLayout.Tab setTag(Object tag)

给这个选项卡一个任意的对象以备后用。

TabLayout.Tab setText(int resId)

设置此选项卡上显示的文字。

TabLayout.Tab setText(CharSequence text)

设置此选项卡上显示的文字。

继承方法(Inherited methods)

From class java.lang.Object

常量(Constants)

INVALID_POSITION

int INVALID_POSITION

选项卡无效的位置。

也可以看看:

常量值:-1(0xffffffff)

公共方法(Public methods)

getContentDescription

CharSequence getContentDescription ()

获取此选项卡的内容的简要说明以用于辅助功能支持。

返回(Returns)
CharSequence Description of this tab's content

也可以看看:

getCustomView

View getCustomView ()

返回用于此选项卡的自定义视图。

返回(Returns)
View

也可以看看:

getIcon

Drawable getIcon ()

返回与此选项卡关联的图标。

返回(Returns)
Drawable The tab's icon

getPosition

int getPosition ()

在操作栏中返回此选项卡的当前位置。

返回(Returns)
int Current position, or INVALID_POSITION if this tab is not currently in the action bar.

getTag

Object getTag ()

返回(Returns)
Object This Tab's tag object.

getText

CharSequence getText ()

返回此选项卡的文本。

返回(Returns)
CharSequence The tab's text

isSelected

boolean isSelected ()

如果当前选中此选项卡,则返回true。

返回(Returns)
boolean

select

void select ()

选择此选项卡。 仅当选项卡已添加到操作栏时才有效。

setContentDescription

TabLayout.Tab setContentDescription (int resId)

设置此选项卡内容的说明以用于辅助功能支持。 如果没有提供内容描述,则将使用标题。

参数(Parameters)
resId int: A resource ID referring to the description text
返回(Returns)
TabLayout.Tab The current instance for call chaining

也可以看看:

setContentDescription

TabLayout.Tab setContentDescription (CharSequence contentDesc)

设置此选项卡内容的说明以用于辅助功能支持。 如果没有提供内容描述,则将使用标题。

参数(Parameters)
contentDesc CharSequence: Description of this tab's content
返回(Returns)
TabLayout.Tab The current instance for call chaining

也可以看看:

setCustomView

TabLayout.Tab setCustomView (int resId)

设置用于此选项卡的自定义视图。

如果膨胀布局包含TextView用的ID text1然后将与给定的值进行更新setText(CharSequence) 同样,如果此布局包含ImageView与ID icon那么它将被给定为值更新setIcon(Drawable)

参数(Parameters)
resId int: A layout resource to inflate and use as a custom tab view
返回(Returns)
TabLayout.Tab The current instance for call chaining

setCustomView

TabLayout.Tab setCustomView (View view)

设置用于此选项卡的自定义视图。

如果所提供的视图包含一个TextView用的ID text1然后将与给定的值进行更新setText(CharSequence) 同样,如果此布局包含ImageView与ID icon那么它将被给定为值更新setIcon(Drawable)

参数(Parameters)
view View: Custom view to be used as a tab.
返回(Returns)
TabLayout.Tab The current instance for call chaining

setIcon

TabLayout.Tab setIcon (Drawable icon)

设置此选项卡上显示的图标。

参数(Parameters)
icon Drawable: The drawable to use as an icon
返回(Returns)
TabLayout.Tab The current instance for call chaining

setIcon

TabLayout.Tab setIcon (int resId)

设置此选项卡上显示的图标。

参数(Parameters)
resId int: A resource ID referring to the icon that should be displayed
返回(Returns)
TabLayout.Tab The current instance for call chaining

setTag

TabLayout.Tab setTag (Object tag)

给这个选项卡一个任意的对象以备后用。

参数(Parameters)
tag Object: Object to store
返回(Returns)
TabLayout.Tab The current instance for call chaining

setText

TabLayout.Tab setText (int resId)

设置此选项卡上显示的文字。 如果没有空间显示整个字符串,文本可能会被截断。

参数(Parameters)
resId int: A resource ID referring to the text that should be displayed
返回(Returns)
TabLayout.Tab The current instance for call chaining

setText

TabLayout.Tab setText (CharSequence text)

设置此选项卡上显示的文字。 如果没有空间显示整个字符串,文本可能会被截断。

参数(Parameters)
text CharSequence: The text to display
返回(Returns)
TabLayout.Tab The current instance for call chaining

Hooray!