summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml6
-rw-r--r--samples/SupportDesignDemos/res/values/strings.xml1
-rw-r--r--samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java9
3 files changed, 16 insertions, 0 deletions
diff --git a/samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml b/samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml
index b249155ed..f25a3ce5f 100644
--- a/samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml
+++ b/samples/SupportDesignDemos/res/layout/design_tabs_viewpager.xml
@@ -62,6 +62,12 @@
android:layout_height="wrap_content"
android:text="@string/remove_tab"/>
+ <Button
+ android:id="@+id/btn_select_first_tab"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:text="@string/select_first_tab"/>
+
</LinearLayout>
<RadioGroup
diff --git a/samples/SupportDesignDemos/res/values/strings.xml b/samples/SupportDesignDemos/res/values/strings.xml
index e65f1403a..c3a981a02 100644
--- a/samples/SupportDesignDemos/res/values/strings.xml
+++ b/samples/SupportDesignDemos/res/values/strings.xml
@@ -49,6 +49,7 @@
<string name="add_tab">Add tab</string>
<string name="remove_tab">Remove tab</string>
+ <string name="select_first_tab">Select tab #0</string>
<string name="form_username">Username</string>
<string name="form_email">Email address</string>
diff --git a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
index ef776e0c6..8efccb530 100644
--- a/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
+++ b/samples/SupportDesignDemos/src/com/example/android/support/design/widget/TabLayoutUsage.java
@@ -85,6 +85,15 @@ public class TabLayoutUsage extends AppCompatActivity {
}
}
});
+
+ findViewById(R.id.btn_select_first_tab).setOnClickListener(new View.OnClickListener() {
+ @Override
+ public void onClick(View view) {
+ if (mTabLayout.getTabCount() > 0) {
+ mViewPager.setCurrentItem(0);
+ }
+ }
+ });
}
private void addRandomTab() {