public class Tab
extends java.lang.Object
implements android.os.Parcelable
TabSwitcher
widget. It has a title, as well as an optional
icon. Furthermore, it is possible to set a custom color and to specify, whether the tab should be
closeable, or not.Modifier and Type | Class and Description |
---|---|
static interface |
Tab.Callback
Defines the interface, a class, which should be notified, when a tab's properties have been
changed, must implement.
|
Modifier and Type | Field and Description |
---|---|
static android.os.Parcelable.Creator<Tab> |
CREATOR
A creator, which allows to create instances of the class
Tab from parcels. |
static java.lang.String |
WAS_SHOWN_PARAMETER
The name of the parameter, which specifies, whether the tab was already shown in a
TabSwitcher , or not. |
Constructor and Description |
---|
Tab(java.lang.CharSequence title)
Creates a new tab, which can be added to a
TabSwitcher widget. |
Tab(android.content.Context context,
int resourceId)
Creates a new tab, which can be added to a
TabSwitcher widget. |
Modifier and Type | Method and Description |
---|---|
void |
addCallback(Tab.Callback callback)
Adds a new callback, which should be notified, when the tab's properties have been changed.
|
int |
describeContents() |
android.content.res.ColorStateList |
getBackgroundColor()
Returns the background color of the tab.
|
android.graphics.drawable.Drawable |
getCloseButtonIcon(android.content.Context context)
Returns the icon of the tab's close button.
|
int |
getContentBackgroundColor()
Returns the background color of the tab's content.
|
android.graphics.drawable.Drawable |
getIcon(android.content.Context context)
Returns the tab's icon.
|
android.os.Bundle |
getParameters()
Returns a bundle, which contains the optional parameters, which are associated with the tab.
|
int |
getProgressBarColor()
Returns the color of the tab's progress bar.
|
java.lang.CharSequence |
getTitle()
Returns the tab's title.
|
android.content.res.ColorStateList |
getTitleTextColor()
Returns the text color of the tab's title.
|
boolean |
isCloseable()
Returns, whether the tab is closeable, or not.
|
boolean |
isProgressBarShown()
Returns, whether the tab's progress bar is shown, or not.
|
void |
removeCallback(Tab.Callback callback)
Removes a specific callback, which should not be notified, when the tab's properties have
been changed, anymore.
|
void |
setBackgroundColor(android.content.res.ColorStateList colorStateList)
Sets the tab's background color.
|
void |
setBackgroundColor(int color)
Sets the tab's background color.
|
void |
setCloseable(boolean closeable)
Sets, whether the tab should be closeable, or not.
|
void |
setCloseButtonIcon(android.graphics.Bitmap icon)
Sets the icon of the tab's close button.
|
void |
setCloseButtonIcon(int resourceId)
Sets the icon of the tab's close button.
|
void |
setContentBackgroundColor(int color)
Sets the background color of the tab's content.
|
void |
setIcon(android.graphics.Bitmap icon)
Sets the tab's icon.
|
void |
setIcon(int resourceId)
Sets the tab's icon.
|
void |
setParameters(android.os.Bundle parameters)
Sets a bundle, which contains the optional parameters, which should be associated with the
tab.
|
void |
setProgressBarColor(int color)
Sets the color of the tab's progress bar.
|
void |
setTitle(java.lang.CharSequence title)
Sets the tab's title.
|
void |
setTitle(android.content.Context context,
int resourceId)
Sets the tab's title.
|
void |
setTitleTextColor(android.content.res.ColorStateList colorStateList)
Sets the text color of the tab's title.
|
void |
setTitleTextColor(int color)
Sets the text color of the tab's title.
|
void |
showProgressBar(boolean show)
Sets, whether the tab's progress bar should be shown, or not.
|
void |
writeToParcel(android.os.Parcel parcel,
int flags) |
public static final java.lang.String WAS_SHOWN_PARAMETER
TabSwitcher
, or not. This parameter should be not be set or modified manually.public Tab(@NonNull java.lang.CharSequence title)
TabSwitcher
widget.title
- The tab's title as an instance of the type CharSequence
. The title may not be
neither be null, nor emptypublic Tab(@NonNull android.content.Context context, @StringRes int resourceId)
TabSwitcher
widget.context
- The context, which should be used, as an instance of the class Context
. The
context may not be nullresourceId
- The resource id of the tab's title as an Integer
value. The resource id must
correspond to a valid string resource@NonNull public final java.lang.CharSequence getTitle()
CharSequence
. The title may
neither be null, nor emptypublic final void setTitle(@NonNull java.lang.CharSequence title)
title
- The title, which should be set, as an instance of the type CharSequence
. The
title may neither be null, nor emptypublic final void setTitle(@NonNull android.content.Context context, @StringRes int resourceId)
context
- The context, which should be used, as an instance of the class Context
. The
context may not be nullresourceId
- The resource id of the title, which should be set, as an Integer
value. The
resource id must correspond to a valid string resource@Nullable public final android.graphics.drawable.Drawable getIcon(@NonNull android.content.Context context)
context
- The context, which should be used, as an instance of the class Context
. The
context may not be nullDrawable
or null, if no custom
icon is setpublic final void setIcon(@DrawableRes int resourceId)
resourceId
- The resource id of the icon, which should be set, as an Integer
value. The
resource id must correspond to a valid drawable resourcepublic final void setIcon(@Nullable android.graphics.Bitmap icon)
icon
- The icon, which should be set, as an instance of the class Bitmap
or null, if
no custom icon should be setpublic final boolean isCloseable()
public final void setCloseable(boolean closeable)
closeable
- True, if the tab should be closeable, false otherwise@Nullable public final android.graphics.drawable.Drawable getCloseButtonIcon(@NonNull android.content.Context context)
context
- The context, which should be used to retrieve the icon, as an instance of the class
Context
. The context may not be nullDrawable
or
null, if no custom icon is setpublic final void setCloseButtonIcon(@DrawableRes int resourceId)
resourceId
- The resource id of the icon, which should be set, as an Integer
value. The
resource id must correspond to a valid drawable resourcepublic final void setCloseButtonIcon(@Nullable android.graphics.Bitmap icon)
icon
- The icon, which should be set, as an instance of the class Bitmap
or null, if
no custom icon should be set@Nullable public final android.content.res.ColorStateList getBackgroundColor()
ColorStateList
or
-1, if no custom color is setpublic final void setBackgroundColor(int color)
color
- The color, which should be set, as an Integer
value or -1, if no custom color
should be setpublic final void setBackgroundColor(@Nullable android.content.res.ColorStateList colorStateList)
colorStateList
- The color state list, which should be set, as an instance of the class ColorStateList
or null, if no custom color should be setpublic final int getContentBackgroundColor()
Integer
value or -1, if no
custom color is setpublic final void setContentBackgroundColor(int color)
color
- The color, which should be set, as an Integer
value or -1, if no custom color
should be set@Nullable public final android.content.res.ColorStateList getTitleTextColor()
ColorStateList
or null, if no custom color is setpublic final void setTitleTextColor(int color)
color
- The color, which should be set, as an Integer
value or -1, if no custom color
should be setpublic final void setTitleTextColor(@Nullable android.content.res.ColorStateList colorStateList)
colorStateList
- The color state list, which should be set, as an instance of the class ColorStateList
or null, if no custom color should be setpublic final boolean isProgressBarShown()
public final void showProgressBar(boolean show)
show
- True, if the progress bar should be shown, false otherwisepublic final int getProgressBarColor()
Integer
value or -1, if the default
color should be usedpublic final void setProgressBarColor(int color)
color
- The color, which should be set, as an Integer
value or -1, if the default
color should be used@Nullable public final android.os.Bundle getParameters()
Bundle
or null, if no parameters are associated with the
tabpublic final void setParameters(@Nullable android.os.Bundle parameters)
parameters
- The bundle, which should be set, as an instance of the class Bundle
or null,
if no parameters should be associated with the tabpublic final void addCallback(@NonNull Tab.Callback callback)
callback
- The callback, which should be added, as an instance of the type Tab.Callback
. The
callback may not be nullpublic final void removeCallback(@NonNull Tab.Callback callback)
callback
- The callback, which should be removed, as an instance of the type Tab.Callback
.
The callback may not be nullpublic final int describeContents()
describeContents
in interface android.os.Parcelable
public final void writeToParcel(android.os.Parcel parcel, int flags)
writeToParcel
in interface android.os.Parcelable