Package icyllis.modernui.widget
Class TabLayout.Tab
java.lang.Object
icyllis.modernui.widget.TabLayout.Tab
- Enclosing class:
TabLayout
A tab in this layout. Instances can be created via
TabLayout.newTab()
.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
An invalid position for a tab. -
Method Summary
Modifier and TypeMethodDescriptionGets a brief description of this tab's content for use in accessibility support.Returns the custom view used for this tab.getIcon()
Return the icon associated with this tab.int
getId()
Returns the id for this tab,View.NO_ID
if not set.int
Return the current position of this tab in the tab layout.int
Gets the visibility mode for the Labels in this Tab.getTag()
getText()
Return the text of this tab.boolean
Returns true if this tab is currently selected.void
select()
Select this tab.setContentDescription
(CharSequence contentDesc) Set a description of this tab's content for use in accessibility support.setCustomView
(View view) Set a custom view to be used for this tab.Set the icon displayed on this tab.setId
(int id) Give this tab an id, useful for testing.setTabLabelVisibility
(int mode) Sets the visibility mode for the Labels in this Tab.Give this Tab an arbitrary object to hold for later use.setText
(CharSequence text) Set the text displayed on this tab.
-
Field Details
-
INVALID_POSITION
public static final int INVALID_POSITIONAn invalid position for a tab.- See Also:
-
-
Method Details
-
getTag
- Returns:
- This Tab's tag object.
-
setTag
Give this Tab an arbitrary object to hold for later use.- Parameters:
tag
- Object to store- Returns:
- The current instance for call chaining
-
setId
Give this tab an id, useful for testing.Do not rely on this if using
TabLayout.setupWithViewPager(ViewPager)
- Parameters:
id
- unique id for this tab
-
getId
public int getId()Returns the id for this tab,View.NO_ID
if not set. -
getCustomView
Returns the custom view used for this tab.- See Also:
-
setCustomView
Set a custom view to be used for this tab.If the provided view contains a
TextView
with an ID ofR.id.text1
then that will be updated with the value given tosetText(CharSequence)
. Similarly, if this layout contains anImageView
with IDR.id.icon
then it will be updated with the value given tosetIcon(Drawable)
.- Parameters:
view
- Custom view to be used as a tab.- Returns:
- The current instance for call chaining
-
getIcon
Return the icon associated with this tab.- Returns:
- The tab's icon
-
getPosition
public int getPosition()Return the current position of this tab in the tab layout.- Returns:
- Current position, or
INVALID_POSITION
if this tab is not currently in the tab layout.
-
getText
Return the text of this tab.- Returns:
- The tab's text
-
setIcon
Set the icon displayed on this tab.- Parameters:
icon
- The drawable to use as an icon- Returns:
- The current instance for call chaining
-
setText
Set the text displayed on this tab. Text may be truncated if there is not room to display the entire string.- Parameters:
text
- The text to display- Returns:
- The current instance for call chaining
-
setTabLabelVisibility
Sets the visibility mode for the Labels in this Tab. The valid input options are:TabLayout.TAB_LABEL_VISIBILITY_UNLABELED
: Tabs will appear without labels regardless of whether text is set.TabLayout.TAB_LABEL_VISIBILITY_LABELED
: Tabs will appear labeled if text is set.
- Parameters:
mode
- one ofTabLayout.TAB_LABEL_VISIBILITY_UNLABELED
orTabLayout.TAB_LABEL_VISIBILITY_LABELED
.- Returns:
- The current instance for call chaining.
-
getTabLabelVisibility
public int getTabLabelVisibility()Gets the visibility mode for the Labels in this Tab.- Returns:
- the label visibility mode, one of
TabLayout.TAB_LABEL_VISIBILITY_UNLABELED
orTabLayout.TAB_LABEL_VISIBILITY_LABELED
. - See Also:
-
select
public void select()Select this tab. Only valid if the tab has been added to the tab layout. -
isSelected
public boolean isSelected()Returns true if this tab is currently selected. -
setContentDescription
Set a description of this tab's content for use in accessibility support. If no content description is provided the title will be used.- Parameters:
contentDesc
- Description of this tab's content- Returns:
- The current instance for call chaining
- See Also:
-
getContentDescription
Gets a brief description of this tab's content for use in accessibility support.- Returns:
- Description of this tab's content
- See Also:
-