diff options
| author | Chris Banes <chrisbanes@google.com> | 2015-06-12 10:04:48 +0100 |
|---|---|---|
| committer | Chris Banes <chrisbanes@google.com> | 2015-06-12 10:19:53 +0100 |
| commit | 1a2ccecaf4ea84b1a9ecadb0bdba6d99a4935abb (patch) | |
| tree | f5a4676d22cbeaa596e282fda6ab6b27bc0e4da2 /design | |
| parent | 1ffa85270d5f9b145c5521e1a3d40323dfb461b2 (diff) | |
| download | android_frameworks_support-1a2ccecaf4ea84b1a9ecadb0bdba6d99a4935abb.tar.gz android_frameworks_support-1a2ccecaf4ea84b1a9ecadb0bdba6d99a4935abb.tar.bz2 android_frameworks_support-1a2ccecaf4ea84b1a9ecadb0bdba6d99a4935abb.zip | |
Add APIs to TabLayout to get selected tab position
BUG: 21796426
Change-Id: I6570a224780a37924576f62a9967cd4d8654fbb0
Diffstat (limited to 'design')
| -rw-r--r-- | design/api/current.txt | 4 | ||||
| -rwxr-xr-x | design/src/android/support/design/widget/TabLayout.java | 16 |
2 files changed, 19 insertions, 1 deletions
diff --git a/design/api/current.txt b/design/api/current.txt index 9dc6e20b9b..b3a6a04da8 100644 --- a/design/api/current.txt +++ b/design/api/current.txt @@ -194,13 +194,13 @@ package android.support.design.widget { method public android.view.View inflateHeaderView(int); method public void inflateMenu(int); method public void removeHeaderView(android.view.View); + method public void setCheckedItem(int); method public void setItemBackground(android.graphics.drawable.Drawable); method public void setItemBackgroundResource(int); method public void setItemIconTintList(android.content.res.ColorStateList); method public void setItemTextAppearance(int); method public void setItemTextColor(android.content.res.ColorStateList); method public void setNavigationItemSelectedListener(android.support.design.widget.NavigationView.OnNavigationItemSelectedListener); - method public void setCheckedItem(int); } public static abstract interface NavigationView.OnNavigationItemSelectedListener { @@ -269,6 +269,7 @@ package android.support.design.widget { method public void addTab(android.support.design.widget.TabLayout.Tab, int); method public void addTab(android.support.design.widget.TabLayout.Tab, boolean); method public void addTab(android.support.design.widget.TabLayout.Tab, int, boolean); + method public int getSelectedTabPosition(); method public android.support.design.widget.TabLayout.Tab getTabAt(int); method public int getTabCount(); method public int getTabGravity(); @@ -306,6 +307,7 @@ package android.support.design.widget { method public int getPosition(); method public java.lang.Object getTag(); method public java.lang.CharSequence getText(); + method public boolean isSelected(); method public void select(); method public android.support.design.widget.TabLayout.Tab setContentDescription(int); method public android.support.design.widget.TabLayout.Tab setContentDescription(java.lang.CharSequence); diff --git a/design/src/android/support/design/widget/TabLayout.java b/design/src/android/support/design/widget/TabLayout.java index 6e0153a8e7..3639261df2 100755 --- a/design/src/android/support/design/widget/TabLayout.java +++ b/design/src/android/support/design/widget/TabLayout.java @@ -426,6 +426,15 @@ public class TabLayout extends HorizontalScrollView { } /** + * Returns the position of the current selected tab. + * + * @return selected tab position, or {@code -1} if there isn't a selected tab. + */ + public int getSelectedTabPosition() { + return mSelectedTab != null ? mSelectedTab.getPosition() : -1; + } + + /** * Remove a tab from the layout. If the removed tab was selected it will be deselected * and another tab will be selected if present. * @@ -1045,6 +1054,13 @@ public class TabLayout extends HorizontalScrollView { } /** + * Returns true if this tab is currently selected. + */ + public boolean isSelected() { + return mParent.getSelectedTabPosition() == mPosition; + } + + /** * Set a description of this tab's content for use in accessibility support. If no content * description is provided the title will be used. * |
